2

i want to display the this url

http://localhost/project/sites/sample/cat.php?typ=Politics

to like this

http://localhost/project/sites/sample/Politics.html

and my htaccess code is

RewriteEngine on
RewriteRule (.*)\.html$ cat.php?typ=$1

it's working when i was gave the url manually on browser, but the url was not loaded dynamically. i want to show the second url dynamical if i click the first url. thank you to help

4 Answers 4

1

Change RewriteRule to Redirect:

RewriteEngine on
Redirect (.*)\.html$ cat.php?typ=$1

*By the way, "typ" is written as "type"

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

Comments

1

Try this Rule:

RewriteEngine on
RewriteRule (.*).html$ cat.php?typ=$1

Comments

1

If you want to redirect form the first URL to the second:

RewriteCond %{QUERY_STRING} ^typ=([a-zA-Z0-9_-]+)$
RewriteRule ^cat\.php$ cat/%1/? [R,L]

If you want to edit the links in your HTML you could try mod_substitute (make sure that mod_filter is also enabled):

AddOutputFilterByType SUBSTITUTE text/html
Substitute s|/?cat\.php\?typ=([a-zA-Z0-9_-]+)|/cat/$1/|i

Comments

1

if you type manually your new link it works right?

simply have your html link point to "Politics.html" instead of "cat.php?typ=Politics" htaccess will take care of the rest

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.