简体   繁体   中英

SEO Friendly URLs & .htaccess

I'm trying to make my URLs SEO friendly but am having issues with my .htaccess

This is how my URL currently looks:

http://www.mysite.com/dns/?domain=stackoverflow.com&submit=Report

But I want it to show like this:

http://www.mysite.com/dns/stackoverflow.com

I've tried so many things I don't know if it's even possible to do so I just wanted to start over with guidance from you guys. The .htaccess I'm working with is in the /dns/ folder. Any help would be greatly appreciated.

Step 1 : change all of your links and anchors in all of your pages to look like this: http://www.mysite.com/dns/stackoverflow.com , so when someone clicks a link on your site, they go to a link that looks like http://www.mysite.com/dns/stackoverflow.com instead of http://www.mysite.com/dns/?domain=stackoverflow.com&submit=Report

Step 2 : In the htaccess file in your document root, add these rules (above any rules that you may already have):

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^/?dns/(.+)$ /dns/?domain=$1&submit=Report [L,QSA]

Step 3 : In the event that a GET method form submission is generating the link, you can add these rules too:

RewriteCond %{THE_REQUEST} ^(GET|HEAD)\ /dns/\?domain=([^&\ ]+)(&submit=Report)?
RewriteRule ^/?dns/?$ /dns/%2? [L,R=301]

See post url rewritin using .HTACCESS

   www.mysite.com/dns/?domain=stackoverflow.com&submit=Report

to

www.mysite.com/dns/stackoverflow.com/Report

Try this

Options +FollowSymLinks

RewriteEngine On
RewriteRule \.(js|css|jpe?g|png|gif)$ - [L]


RewriteRule "^dns/([ \w-]+)/([ \w-]+)/?$" dns/?domain=$1&submit=$2 [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