1

i have problem with my htaccess code the problem is i dont know how can i display the code for index.php , the code that i'm using is

RewriteEngine On
  RewriteRule ^Page/([^/]*)$ /Page.php?v=$1 [L]

and my output link is www.expample.com/Page/1

the code above sis working for every thing except the index page

what i need to do now is

index.php instead of Page.php

i tried this way

       RewriteRule ^/([^/]*)$ /index.php?v=$1 [L]

but also it's not working

the output that i need now is to convert the link from

www.example.com/index.php?v=1 to www.example.com/1

4 Answers 4

2

For second index.php rule you need to use RewriteCond to avoid rewriting for files or directories:

Options -MultiViews
RewriteEngine On

RewriteRule ^Page/([^/]*)$ Page.php?v=$1 [L,QSA,NC]

# if request is not for a file
RewriteCond %{REQUEST_FILENAME} !-d
# if request is not for a directory
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^/]+)/?$ index.php?v=$1 [L,QSA]
Sign up to request clarification or add additional context in comments.

Comments

0

Try This

RewriteRule ^1/?$ index.php?v=1 [QSA,L]

I think you should not use /index.php try index.php

Comments

0

You can use the following rule to rewrite to your index.php

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^/]+)/?$ index.php?v=$1 [L]

Comments

0

Try something like this:

RewriteBase /
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s(.*)/index.php/?([^\ \?]*) [NC]
RewriteRule ^ %1/%2 [R=301,L]

That should handle any location of /index.php.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.