I have a website that uses Symfony3 and am trying to integrate a wordpress blog under www.website.com/blog.
So what I've done so far is create a blog folder, under the Symfony web folder, which contains the wordpress files.
I've then added a rewrite rule, in the web/ directory's .htaccess file so that when we are under blog/, Symfony's url rewriting won't do anything :
# Passing through the Url rewriting for all blog/ urls
RewriteRule ^blog/(.*)$ blog/$1 [PT]
So far it's good. I can access the admin section and everything but the problem is that when I try to access www.website.com/blog or even www.website.com/blog/index.php I only get the list of files in the folder and not the actual front page.
And here is the .htaccess file from blog/ folder that was created when I launched the wordpress installation script:
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /xxx/web/blog/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /xxx/web/blog/index.php [L]
</IfModule>
# END WordPress
Any ideas why ?
I think that if you have access to the sites-available's configuration file for your site, i.e. /etc/apache2/sites-available/mysite.conf.
And add a <Directory> for your blog with the WordPress rules:
<Directory /var/www/mysite/web/blog>
DirectoryIndex index.php
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /blog/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /blog/index.php [L]
</IfModule>
# END WordPress
</Directory>
Note: I have added DirectoryIndex index.php by myself because my Symfony have a DirectoryIndex app.php or DirectoryIndex disabled.
If you don't have access to your configuration file, probably you need to add the DirectoryIndex index.php to your .httaccess but then your configuration site and the .httaccess of Symfony should allow this directive, e.g., they should contain AllowOverride All or AllowOverride Indexes FileInfo.
Related
I want to setup cakephp 3.x solution inside WP website.
On my bluehost server, I have directory structure in public_html is as follows:
I want to access stagetribescrm directory and that directory contains Cakephp 3.x file structure.
.
Code Inside of public_html/stagetribescrm/.htaccess file.
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /stagetribescrm/
# RewriteRule ^$ webroot/ [L]
# RewriteRule (.*) webroot/$1 [L]
</IfModule>
Code Inside of public_html/stagetribescrm/webroot/.htaccess file.
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</IfModule>
And the problem with this code is that it couldn't load css and js files inside webroot folder's file.
Thanks.
Please check for rewrite module is turn on or not in bluehost server than
follow below link:
http://www.abhinavsood.com/install-cakephp-in-subdirectory-of-wordpress/
I'm try to use my Symphony 2 project without the /web slug in URL. I've added the following to the .htaccess file in my root folder (localhost/subdir).
<IfModule mod_rewrite.c>
Options +FollowSymlinks
RewriteEngine On
# Explicitly disable rewriting for front controllers
RewriteRule ^web/app_dev.php - [L]
RewriteRule ^web/app.php - [L]
# Fix the bundles folder
RewriteCond %{HTTP_HOST} ^localhost/subdir/$
RewriteRule ^bundles/(.*)$ /web/bundles/$1 [QSA,L]
RewriteCond %{HTTP_HOST} ^localhost/subdir/$
RewriteCond %{REQUEST_FILENAME} !-f
# Change below before deploying to production
#RewriteRule ^(.*)$ /web/app.php [QSA,L]
RewriteRule ^(.*)$ web/app_dev.php [QSA,L]
</IfModule>
This script loads my page, but It do not get any /web/bundle/mybundle/javascript/, /images/, or /css/ files. These are giving me a 404 error. Because in the <head> tag it says /bundle/mybundle/javascript/ without the /web prefix. The same is on web-profiler, debug toolbar etc.
How can I fix my .htaccess to make this work?
the web/ folder is ment to be the root web directory
so you have a misconfiguration, tell your apache to have web as document root. in httpd.conf sth. like:
<VirtualHost *:80>
ServerName name.localhost.com
DocumentRoot "/Projects/name/web"
<Directory "/Projects/name/web">
Options Indexes FollowSymLinks
AllowOverride All
Allow from All
</Directory>
</VirtualHost>
otherwise for example your parameters.yml with database pass and so on could be accessible.
the web/.htaccess conf for rewrite the app.php/app_dev.php in url could look ike :
# Use the front controller as index file. It serves as a fallback solution when
# every other rewrite/redirect fails (e.g. in an aliased environment without
# mod_rewrite). Additionally, this reduces the matching process for the
# start page (path "/") because otherwise Apache will apply the rewriting rules
# to each configured DirectoryIndex file (e.g. index.php, index.html, index.pl).
DirectoryIndex app.php
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_URI}::$1 ^(/.+)/(.*)::\2$
RewriteRule ^(.*) - [E=BASE:%1]
RewriteCond %{ENV:REDIRECT_STATUS} ^$
RewriteRule ^app.php(/(.*)|$) %{ENV:BASE}/$2 [R=301,L] ##### this is the part that you should tweak, have the .htaccess point the request to app_dev.php, since the routing.yml is empty initially
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule .? - [L]
RewriteRule .? %{ENV:BASE}/app.php [L] ##### this is the part that you should tweak, have the .htaccess point the request to app_dev.php, since the routing.yml is empty initially
</IfModule>
<IfModule !mod_rewrite.c>
<IfModule mod_alias.c>
# When mod_rewrite is not available, we instruct a temporary redirect of
# the startpage to the front controller explicitly so that the website
# and the generated links can still be used.
RedirectMatch 302 ^/$ /app.php/
# RedirectTemp cannot be used instead
</IfModule>
</IfModule>
So I have been looking all over for a while, and cannot seem to find a particular solution I am looking for. I have seen many articles showing how to fix problems with wordpress rewrite, but none fix my problem.
I currently have Wordpress Installed in my / Root directory. the .htaccess looks like this.
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^manager - [L,NC] <-- I added this from other examples.
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
So from what I can tell this tells wordpress, hey you will handle all the urls, for everything. forever. Seriously. For ever and everywhere :P
So the problem comes when I have a sub directory site.com/manager
Here I would like to build a similar URL capturing method to manage what the user gets to see/access/etc. The line I added to the root .htaccess file (from what I have read) is suppose to tell wordpress, hey don't touch my damn /manager folder.
Wordpress being the sneaky greedy caregiver that it is fails to listen. ill go to test my site.com/manager/test (grabbing test and pulling info from sql with it) and wordpress takes over and throws me to the wordpress 404 page.
my .htaccess in /manager is as follows for refrence, I am thinking I will need to do some rewrite stuffs here too, but for now just trying to prevent wordpress from being over bearing :).
DirectoryIndex index.php
<FilesMatch "\.(php|inc)$">
Order allow,deny
deny from all
</FilesMatch>
<FilesMatch "(index.php|logout.php)$">
Order allow,deny
allow from all
</FilesMatch>
Any ideas, thoughts, comments, concerns would be much appreciated.
Thank you.
SO after digging deeper and looking into this further I found a fix. Not sure it is the BEST solution but its working.
Root (/) .htaccess
#Manager - A customer content manager
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI} ^/manager/(.*)$ [OR]
RewriteRule ^.*$ - [L]
</IfModule>
#end Manager
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
This appears to over ride wordpress like needed.
Manager (/manager) .htaccess
DirectoryIndex index.php
<FilesMatch "\.(php|inc)$">
Order allow,deny
deny from all
</FilesMatch>
<FilesMatch "(index.php|logout.php|install.php)$">
Order allow,deny
allow from all
</FilesMatch>
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /manager/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . index.php [L]
</IfModule>
The top portion isn't required but I added this for file protection/security.
Summary:
I used the %{REQUEST_URI} to selectively remove a sub-folder, to apply this to more sub-folders I would add another
RewriteCond %{REQUEST_URI} ^/manager/(.*)$ [OR]
I then input the information in the sub-directory's .htaccess file for url rewriting. From here I can manipulate the URL converting it into a Array list for further sorting and database calling.
I have recently added a .htaccess file to my website root in order to achieve something I have already asked in this question:
Create blog post links similar to a folder structure
Now, the top answer was brilliant and it worked on localhost, however on my server it doesn't.
To be honest with you, I am not quite sure what these statements in the .htaccess mean exactly. I would be grateful if somebody could explain them line by line.
So this is what I have
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
<IfModule mod_rewrite.c> # If the module for rewrite is available
RewriteEngine On # turn it on
RewriteBase / # set / to the relative root path
RewriteRule ^index\.php$ - [L] # don't rewrite index.php and stop the rest of the rules
RewriteCond %{REQUEST_FILENAME} !-f # if file does not exist
RewriteCond %{REQUEST_FILENAME} !-d # and file is not a directory
RewriteRule . /index.php [L] # show the index page instead
</IfModule> # close the IfModule clause
I suspect if it doesn't work on your server, that the root directory isn't set properly for the domain or server configuration. You'll wanna look into where the files are placed and how the httpd.conf is configured to use those paths.
Also, for next time Apache has a wonderful documentation on this module that should cover everything I've just said, in more depth.
The actual problem was that the rewrite was not enabled on my virtualhost.
So I enabled it in my virtualhosts and everything works now.
<VirtualHost *>
ServerName mysite.com
DocumentRoot /var/www/html/mysite.com
<Directory /var/www/html/mysite.com>
Options FollowSymLinks
AllowOverride all
</Directory>
</VirtualHost>
I am currently hosting a website using the Silex framework on a shared server and I have a problem...
Silex is like Symfony, there is an app.php file located in a /web/ subfolder : the website is then only accessible via the URL website.com/web/. I cannot create a virtual host as it is a shared server, so I think the solution is to use an .htaccess file...
I managed to redirect website.com to website.com/web/ automatically but I don't really like this option. I would rather website.com pointed directly to website.com/web/ but I don't know how to do this by just using a .htaccess file. I have been trying to solve this problem for hours now and it's killing me...
At the moment I use this file :
<IfModule mod_rewrite.c>
Options -MultiViews
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ web/app.php [QSA,L]
</IfModule>
but it just redirects you from website.com to website.com/web
Is there anyway I can make the root url directly point to the /web folder with a .htaccess file?
Thank you very much :)
If you want access to http://example.com/subdirectory just by typing http://example.com this should work.
# .htaccess main domain to subdirectory redirect
RewriteEngine on
# Change example.com to be your main domain.
RewriteCond %{HTTP_HOST} ^(www.)?example.com$
# Change 'subdirectory' to be the directory you will use for your main domain.
RewriteCond %{REQUEST_URI} !^/subdirectory/
# Don't change the following two lines.
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# Change 'subdirectory' to be the directory you will use for your main domain.
RewriteRule ^(.*)$ /subdirectory/$1
# Change example.com to be your main domain again.
# Change 'subdirectory' to be the directory you will use for your main domain
# followed by / then the main file for your site, index.php, index.html, etc.
RewriteCond %{HTTP_HOST} ^(www.)?example.com$
RewriteRule ^(/)?$ subdirectory/ [L]
Try this htaccess configuration:
DirectoryIndex web/app.php
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_URI} !^/web/
RewriteRule (.*) /web/$1
</IfModule>
<IfModule !mod_rewrite.c>
<IfModule mod_alias.c>
# When mod_rewrite is not available, we instruct a temporary redirect of
# the start page to the front controller explicitly so that the website
# and the generated links can still be used.
RedirectMatch 302 ^/$ /web/app.php/
# RedirectTemp cannot be used instead
</IfModule>
</IfModule>