简体   繁体   中英

URL rewriting- How can I turn example.com/pageid.php?id=12 to example.com/full-title

I want to make my pages search engine friendly and it also looks better that example.com/pageid.php?id=12

I have pages different pages like showUser.php showLocation.php and I want all these to be rewritten.

Wo'nt mod_rewrite slow down my app a little bit?

您需要看一下mod_rewrite(只要您的主机支持它)-这是一篇有关该主题的不错的博客文章

In your particular example, mod_rewrite could be set up something like this:

# .htaccess
RewriteEngine on
RewriteRule ^/([\w-]+)$ /page.php?title=$1

Now, a request to /full-title would resolve to page.php and $_GET['title'] would hold the value 'full-title' .

(Most web frameworks (such as Symfony, Django etc.) allow for customizable URL routing rules which do not require you to hardcode rewrite rules in your .htaccess file.)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM