How to make dynamic pages seo friendly url using h

2019-06-14 02:43发布

In my php page i have given link as href="test.php?category="xyz". In url I want this page link to appear as "test/xyz".

In my .htaccess file i have added

RewriteRule ^test/([a-zA-Z]+) test.php?category=$

but this does'nt work for me.

All the other links in test.php gets test appended to their links. eg. if there was example.php its appears as test/example.php

Help is appreciated. Thanks in advance

2条回答
神经病院院长
2楼-- · 2019-06-14 03:08

Maybe this code can help you

<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^test/([a-zA-Z]+)$ test.php?category=$1
</IfModule>

Try to access these urls : test.php?category=abc and test/abc. If two pages show the same content this code successful.
To learn more, please read the reference here

查看更多
干净又极端
3楼-- · 2019-06-14 03:17

This sounds more like you forgot the use full relative paths in your links. Instead of using:

<a href="example.php">example</a>

You should use:

<a href="/example.php">example</a>

Else when you are on page /test/abcd, going to example.php means /test/example.php

查看更多
登录 后发表回答