Reputation: 43
I am getting some problem for without trailing slash url. I searched in Google, but not able to get the exact result.
From Url : local.xxxx.com/stories
When I am trying with the above Url, It redirects to
To Url : local.xxxx.com/sapp/View//stories/
Htaccess:
DirectorySlash Off
RewriteEngine On
RewriteCond %{DOCUMENT_ROOT}/app/View/%{REQUEST_URI} -f [OR]
RewriteCond %{DOCUMENT_ROOT}/app/View/%{REQUEST_URI} -d
RewriteRule ^ /app/View/%{REQUEST_URI} [L]
Now I am getting 403 Forbidden error. You don't have permission to access /app/View//storieson this server.
If I will add trailing slash, then its working perfectly. If there is no slash, we can add slash at the end of the url if there are no params.
Can any body suggest how can I achieve this.
Upvotes: 3
Views: 679
Reputation: 784998
It is most likely due to the fact that /app/View/stories/
is a real directory and Apache's mod_dir
is adding a trailing slash.
You can fix using this code:
DirectorySlash Off
RewriteEngine On
# internally add a trailing slash to directories
RewriteCond %{DOCUMENT_ROOT}/app/View/%{REQUEST_URI} -d
RewriteRule [^/]$ /app/View/%{REQUEST_URI}/ [L]
RewriteCond %{DOCUMENT_ROOT}/app/View/%{REQUEST_URI} -f [OR]
RewriteCond %{DOCUMENT_ROOT}/app/View/%{REQUEST_URI} -d
RewriteRule ^ /app/View/%{REQUEST_URI} [L]
Upvotes: 1