Reputation: 183
I have a laravel installation and a wordpress living side by side. in the root I have an .htaccess as follows:
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews
</IfModule>
RewriteEngine On
# Redirect Trailing Slashes...
RewriteRule ^(.*)/$ /$1 [L,R=301]
# Handle Front Controller...
RewriteCond %{REQUEST_URI} !^/cms
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
RewriteCond %{REQUEST_URI} ^/cms
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ cms.php [L]
</IfModule>
I need to have all requests routed through index.php unless they are prefixed with /cms/ then I need it to be sent through cms.php which is the old index.php for Wordpress.
I thought the code above would do the trick, but I seem mistaken :)
Not sure where I am going wrong
Thanks
Upvotes: 0
Views: 77
Reputation: 143906
That seems to be my problem :) where I am I causing that to occur?
There's a few things happening here, but it involves this rule:
# Redirect Trailing Slashes...
RewriteRule ^(.*)/$ /$1 [L,R=301]
This rule will remove all trailing slashed by redirecting to the same URL without it. There's also this module in apache called mod_dir which will automatically redirect any request for a directory without the trailing slash to the same URL with the trailing slash.
This means you have 2 options:
For #1, you'll run into this security warning:
Turning off the trailing slash redirect may result in an information disclosure. Consider a situation where mod_autoindex is active (Options +Indexes) and DirectoryIndex is set to a valid resource (say, index.html) and there's no other special handler defined for that URL. In this case a request with a trailing slash would show the index.html file. But a request without trailing slash would list the directory contents.
So in other words, if you have auto indexing, people will be able to see the list of files in your directories even if you have an index.html file (or whatever directory index you use).
For #2, you just need to add a condition:
# Redirect Trailing Slashes...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)/$ /$1 [L,R=301]
Upvotes: 1