thx replacing
- Code: Select all
/$1.php
with
- Code: Select all
/folder/$1.php
http://localhost/site works but
http://localhost/ doesn't work
replacing
- Code: Select all
index\.php
with
- Code: Select all
index(\.php)?
no result so I deleted it.
As I said before -
http://localhost/ didn't work so I have added my own code to Your very, very complicate code (
):
- Code: Select all
# For http://localhost/
RewriteRule ^$ folder/index.php [L]
and
http://localhost/ works now. (I am not sure if this code is ok so correct me if something is wrong)
I would like to use also for example address
<a href="http://localhost/site/a/1/b/2">site</a>
like
<a href="http://localhost/folder/site.php?a=1&b=2">site</a>
so I have added:
- Code: Select all
# For http://localhost/site/a/1/b/2
RewriteRule ^(.+)/(.*)/(.*)/(.*)/(.*)$ /folder/$1.php?$2=$3&$4=$5 [L]
it works for:
<a href="http://localhost/site/a/1/b/2">site</a>
but not for:
<a href="http://localhost/site/a/1">site</a>
Why ?
So I have got now:
- Code: Select all
Options +FollowSymLinks
RewriteEngine On
# For http://localhost/ - this is my own code:
RewriteRule ^$ folder/index.php [L]
# Redirect to remove /index.php files.
RewriteCond %{THE_REQUEST} \ /(.+/)?index\.php(\?.*)?\ [NC]
RewriteRule ^(.+/)?index\.php$ /%1 [NC,R=301,L]
# Redirect to remove .php
RewriteCond %{ENV:REDIRECT_STATUS} ^$
RewriteCond %{DOCUMENT_ROOT}/folder%{REQUEST_URI} -f
RewriteRule ^(.+)\.php$ /$1 [R=301,L]
# Rewrite to add .php back.
RewriteCond %{DOCUMENT_ROOT}/folder%{REQUEST_URI}.php -f
RewriteRule ^(.*[^/])$ /folder/$1.php [QSA,L]
# For http://localhost/site/a/1/b/2 - this is my own code:
RewriteRule ^(.+)/(.*)/(.*)/(.*)/(.*)$ /folder/$1.php?$2=$3&$4=$5 [L]
What is wrong ? Why I can use
http://localhost/site/a/1/b/2 but not
http://localhost/site/a/1 ?