0

I have htaccess like this

RewriteRule i_am_(.*)_fan([0-9]).html$ /fans.php?player=$1&page=$2

When i enter url like this http://messi_fans.com/i_am_messi_fan2.html.it redirect to the page http://messi_fans.com/fans.php. But the GET variable is

Array ( [player] => messi_fan2 [page] => ) 

I want GET like this Array ( [player] => messi [page] =>2 ) How to modify above htaccess?

3 Answers 3

1

Start by using at least the basic directives and some condition to prevent a loop, like this:

Options +FollowSymlinks -MultiViews
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI}  !fans\.php                        [NC]
RewriteCond %{REQUEST_URI}  ^/i_am_([^_]+)_fan([^.]+)\.html/? [NC]
RewriteRule .*              fans.php?player=%1&page=%2        [L]

Map silently

http://messi_fans.com/i_am_messi_fan2.html with or without trailing slash

To:

http://messi_fans.com/fans.php?player=messi&page=2

For permanent and visible redirection, replace [L] with [R=301,L]

Sign up to request clarification or add additional context in comments.

Comments

0

You should use a lazy quantifier by appending a question mark to your .*:

i_am_(.*?)_fan([0-9]).html$

Comments

0

it should be

RewriteRule i_am_([a-zA-Z])_fan([0-9]).html$ /fans.php?player=$1&page=$2

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.