简体   繁体   中英

How can I rewrite this kind of URL with htaccess

How can I rewrite this kind of url with htaccess .. the example is below with these dummy urls

update the .htaccess so when someone goes to http://cheapbats.mediagroup.com/19 it redirects them to http://cheapbats.cmediagroup.com/index.php?ref=19

The rule is, if not a directory or file, and it is a number, then redirect it to index.php? ref=[number]

You can try this rule in your DOCUMENT_ROOT/.htaccess file:

RewriteEngine On

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([0-9]+)/?$ /index.php?ref=$1 [L,QSA]

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