简体   繁体   中英

URL Rewrite Rule .htaccess

I need to create a rewrite rule for the following URL and I need to pass "id" and widget with the GET superglobal

http://www.domain.com/index.php?id=1866&widget=Dangerfield

Is it possible to only use the widget parameter & value in the re-written URL and still be just as functional, and if so, how?

Simple you'd add this to your .htaccess

RewriteEngine On
RewriteRule ^([^/]*)/([^/]*)\.html$ /index.php?id=$1&widget=$2 [L]

The original URL:

http://www.domain.com/index.php?id=1866&widget=Dangerfield

The rewritten URL:

http://www.domain.com/1866/Dangerfield.html

This is search engine friendly, your pages would be easily SEOed in search engines with a .html extension. It's better than having parameter at the end of the url which isn't seo friendly.

Steering assistance subdomain

The original URL:

http://domain.com/index.php?cat=cats&id=12&url=stackoverflow

The rewritten URL:

http://cats.domain.com/12/stackoverflow.html

Code to rewrite rule for above in .htaccess

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