Reputation: 21
I know there are many topics. I tried them many times, but it doesn't work.
Instead of example.com/en/file.php
, users see only example.com/en/file
.
DirectoryIndex index.php index.html
RewriteEngine on
*RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^(.*)$ /$1.php*
ErrorDocument 404 /index.php
RewriteCond %{HTTP_HOST} ^example\.com$ [OR]
RewriteCond %{HTTP_HOST} ^www\.example\.com$
RewriteRule ^ru\/index\.php$ "http\:\/\/example\.com\/ru\/" [R=301,L]
RewriteCond %{HTTP_HOST} ^example\.com$ [OR]
RewriteCond %{HTTP_HOST} ^www\.example\.com$
RewriteRule ^en\/index\.php$ "http\:\/\/example\.com\/en\/" [R=301,L]
etc. for every language
What do I have to add to hide extensions?
After it works, should I use links between pages as "file.php" or only "file"?
Upvotes: 0
Views: 802
Reputation: 21
Fixed by adding one line:
RewriteEngine on
**Options -Multiviews**
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+)$ $1.php [L,QSA]
Upvotes: 0
Reputation: 820
DirectoryIndex index.php index.html
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+)$ $1.php [L,QSA]
In your links, don't use extensions.
Upvotes: 0
Reputation: 29188
Perhaps something like this. Modify as you see fit for more specific pattern matching.
RewriteRule ^(?:(.*)/)?(.*)$ $2.php?lang=$1
Rewrites:
/en/fun => /fun.php?lang=en
/ru/fun => /fun.php?lang=ru
/fun => /fun.php?lang=
Upvotes: 1