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.
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]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With