Yesterday I posted a question about the file .htaccess. Now is working, but I have another problem. For example:
When I try to go to "localhost/about", it doesn't work, it gives me an "Error 404":
Not Found
The requested URL /Applications/MAMP/htdocs/user/enric/ was not found on this server.
But when I go to "localhost/about/" it works. Why?
I want both URL's to work. Can anybody help me?
This is the code of my .htaccess file:
<IfModule mod_rewrite.c>
Options -Multiviews
Options +FollowSymLinks
RewriteEngine On
RewriteRule ^channels/page/([0-9]+)/?$ channels/index.php?p=$1 [L]
RewriteRule ^channels/([_0-9a-z-]+)/?$ channels/index.php?o=$1 [L]
RewriteRule ^channels/([_0-9a-z-]+)/([0-9]+)/?$ channels/index.php?o=$1&p=$2 [L]
# User profiles
RewriteRule ^user/([^/]*)/$ /user/index.php?usr=$1 [L]
# Check to see if the URL points to a valid file
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# Trailing slash check
RewriteCond %{REQUEST_URI} !(.*)/$
# Add slash if missing & redirect
RewriteRule ^(.*)$ $1/ [L,R=301]
# Delete ".php" extension and adds "/"
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{THE_REQUEST} ^GET\ /[^?\s]+\.php
RewriteRule (.*)\.php$ /$1/ [L,R=301]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} ^(.+)/$
RewriteCond %{DOCUMENT_ROOT}%1.php -f
RewriteRule (.*)/$ $1.php [L]
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule .*[^/]$ $0/ [L,R=301]
</IfModule>
Thanks!
Try this slightly modified code in your DocumentRoot/.htaccess
:
Options +FollowSymLinks -Multiviews
RewriteEngine On
RewriteRule ^channels/page/([0-9]+)/?$ channels/index.php?p=$1 [L]
RewriteRule ^channels/([_0-9a-z-]+)/?$ channels/index.php?o=$1 [L]
RewriteRule ^channels/([_0-9a-z-]+)/([0-9]+)/?$ channels/index.php?o=$1&p=$2 [L]
# User profiles
RewriteRule ^user/([^/]*)/$ /user/index.php?usr=$1 [L]
# Check to see if the URL points to a valid file
RewriteCond %{REQUEST_FILENAME} !-f
# Trailing slash check
RewriteCond %{REQUEST_URI} !(.*)/$
# Add slash if missing & redirect
RewriteRule ^(.*)$ $1/ [L,R=301]
# Delete ".php" extension and adds "/"
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{THE_REQUEST} \s/[^?\s]+\.php
RewriteRule (.*)\.php$ /$1/ [L,R=301]
RewriteCond %{REQUEST_URI} ^(.+)/$
RewriteCond %{DOCUMENT_ROOT}%1.php -f
RewriteRule (.*)/$ $1.php [L]
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI}.php -f
RewriteRule [^/]$ %{REQUEST_URI}/ [L,R=301]