I’m using with good results the following code to access alla of my php files into the /it directory without specifying the extension. In other words I can access to “http://www.mydomain.com/it/about.php” just writing “http://www.mydomain.com/it/about”.
Options -MultiViews
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ http://www.mydomain.com/it/$1.php [L]
the same happen when i try to access to http://www.mydomain.com/it/question_answers.php.
How can I access directly to *”http://www.mydomain.com/it/question_answers.php”* also writing “http://www.mydomain.com/it/question-answers”?
I wrote the floowing code below the previous but it seems not to work.
Redirect 301 /question-answer http://www.mydomain.com/it/question_answer.php
because if i write “http://www.mydomain.com/it/question-answer” the browser try to open the page:
“http://www.mydomain.com/it/question-answer.php.php.php.php.php.php.php.php.php.php.php.php.php.php.php.php.php.php.php.php”
A small abstract of the post:
- I have the page *”http://www.mydomain.com/it/question_answers.php”*
- with the first part of code I can get it using the link *”http://www.mydomain.com/it/question_answers”*
- I’d like to access the same page also with the following “http://www.mydomain.com/it/question-answers”
Thanks!
This should work for you:
I have changed two things: I deleted
it/in the new URL of the first RewriteRule. Otherwise you would be redirected toit/it/I also added
\.phpto the second RewriteRule. I don’t really know why, but the RewriteRule seems to replace the pattern instead of redirecting. And if your pattern isit/question-answerand the real url isit/questions-answer.phpthe.phpwill not be replaced.