Forum Moderators: phranque
RewriteRule ^pecatscapitals$ pecatscapitals.php [L]
RewriteRule ^meninaton$ meninaton.php [L]
RewriteRule ^novetats$ novetats.php [L]
RewriteRule ^entreoberts$ entreoberts.php [L] RewriteRule ^(.*)$ $1.php [L] /something" URL request to fetch the /something.php file, the htaccess file is checked again and /something.php matches the (.*) pattern and is rewritten to /something.php.php and the htaccess file is checked again and /something.php.php matches the (.*) pattern and is rewritten to /something.php.php.php and the htaccess file is checked again and /something.php.php.php matches the (.*) pattern and is rewritten to /something.php.php.php.php and this continues until the server traps the error and returns HTTP "Error 500 - Internal Server Error" status. (.*) is almost always bad, because you're effectively asking your PHP script to deal with requests for robots.txt, css and js files, images and WMT and analytics verification files. (.*) as the pattern, use a more specific pattern. For best results use extensionless URLs and limit the pattern to match only requests without extensions. ^([^.]+)$ or ^([^/.]+)$ or ^(([^/]+/)*[^/.]+)$ or ^([a-z0-9-]+)$ or ^(([a-z0-9-]+/)*[a-z0-9-]+)$ depending on exactly what you do want to match. [edited by: g1smd at 1:57 pm (utc) on Mar 23, 2013]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_fileNAME} !-d
RewriteCond %{REQUEST_fileNAME} !\.html$
RewriteRule ^(.*)$ $1.php [L]
RewriteRule ^(([a-z0-9-]+/)*[a-z0-9-]+)$ /$1.php [L] Perhaps there is another problem, but
RewriteRule ^(([a-z0-9-]+/)*[a-z0-9-]+)$ /$1.php [L]
neither
RewriteRule ^([^./]+)$ /$1.php [L]
works for me.
and the folder where are all the files is localhost:8887/francana
RewriteRule ^([^.]+)$ $1.php [L] The problem that I have is that it changes my root folder.
The real root folder is:
http:/ /localhost:8887/francana
the friendly url is:
http:/ /localhost:8887/francana/pecatscapitals/ca
and then all relatives address are:
http:/ /127.0.0.1:8887/francana/pecatscapitals/....
instead of
http:/ /127.0.0.1:8887/francana/....
To solve it I've added
<base href="http://localhost:8887/francana/" target="_blank">
to the web.
href="/something" or href="/folder/something" beginning with a leading slash. RewriteRule ^([^.]+)/([^.]+)$ $1.php?idioma=$2 [L] RewriteRule ^([^/]+)/([^.]+)$ /$1.php?idioma=$2 [L] RewriteRule ^([^/]+)/([^.]+)$ /folder/$1.php?idioma=$2 [L] ([^.]+)/ says "Keep on parsing characters that are not a dot. Stop when you find a dot. Match that character (the dot) to see if it is a slash." The rule will always fail and the regEx parser will have to perform multiple "back off and retry" trial matches to see what you actually meant. ([^/]+)/ which says "Keep on parsing characters that are not a slash. Stop when you find a slash. Check the slash is a slash, then ([^.]+)$ parse all characters that are not a dot - until the end."
#Redirect to friendly URL
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /([a-z]+)\.php\?id=([a-z]+)\ HTTP/
RewriteRule ^([a-z]+)\.php http://www.example.com/$1/%2 [R=301,L]
#Redirect to canonical hostname
RewriteCond %{HTTP_HOST} !^(www\.example\.com)?$
RewriteRule (.*) http://www.example.com/$1 [R=301,L]
#Rewrite internal
RewriteRule ^([^/]+)/([^.]+)$ /$1.php?id=$2 [L] RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /folder/([a-z]+)\.php\?id=([a-z]+)\ HTTP/
RewriteRule ^folder/([a-z]+)\.php http://www.example.com/$1/%2 [R=301,L] RewriteRule ^([^/]+)/([^.]+)$ /folder/$1.php?id=$2 [L]