friendly URL
8 posts
• Page 1 of 1
friendly URL
Hi,
What would be the code to have this link:
http://www.mysite.com/Webpage.aspx?Webp ... Id=15.aspx
Look like this:
http://www.mysite.com/Nutrition-Info
THanks,
What would be the code to have this link:
http://www.mysite.com/Webpage.aspx?Webp ... Id=15.aspx
Look like this:
http://www.mysite.com/Nutrition-Info
THanks,
- HeliconAndrew
- Posts: 1264
- Joined: 07 Mar 2012, 10:16
Re: friendly URL
Do you want it to be a single-url rule? Or do you want to create a universal rule for a large group, using mapfiles?
Regards
Andrew
Regards
Andrew
Re: friendly URL
Hi Andrew,
I am probably going to use a map file and if you could just give me a hand with this one and how the format should be, I could probably just add to the map file for the rest. Thanks for your help I appreciate it!
John
I am probably going to use a map file and if you could just give me a hand with this one and how the format should be, I could probably just add to the map file for the rest. Thanks for your help I appreciate it!
John
- HeliconAndrew
- Posts: 1264
- Joined: 07 Mar 2012, 10:16
Re: friendly URL
Hello,
Try using the following:
file mapfiel.txt must be located in the same folder with .htaccess(or httpd.conf - the same place where the rules are located).
Content of the mapfile is:
You may find out more about mapfiles here
regards
Andrew
Try using the following:
- Code: Select all
RewriteEngine on
RewriteBase /
RewriteMap mapfile txt:mapfile.txt
RewriteCond %{QUERY_STRING} ^(.*)$
RewriteCond ${mapfile:%1|NOT_FOUND} !NOT_FOUND
Rewriterule ^Webpage\.aspx$ /${mapfile:%1} [NC,R=301,L]
file mapfiel.txt must be located in the same folder with .htaccess(or httpd.conf - the same place where the rules are located).
Content of the mapfile is:
WebpageId=106&CategoryId=15.aspx Nutrition-Info
WebpageId=106&CategoryId=145 OtherPage
WebpageId=1342&CategoryId=187 AntherPage
You may find out more about mapfiles here
regards
Andrew
Re: friendly URL
This is really close, but it's coming back now as
http://www.mysite.com/Nutrition-Info?We ... Id=15.aspx
and I need it to be just
http://www.mysite.com/Nutrition-Info
Any ideas?
Thanks,
http://www.mysite.com/Nutrition-Info?We ... Id=15.aspx
and I need it to be just
http://www.mysite.com/Nutrition-Info
Any ideas?
Thanks,
- HeliconAndrew
- Posts: 1264
- Joined: 07 Mar 2012, 10:16
Re: friendly URL
Sorry, alway forget about that. Please, replace
with
Regards
Andrew
- Code: Select all
Rewriterule ^Webpage\.aspx$ /${mapfile:%1} [NC,R=301,L]
with
- Code: Select all
Rewriterule ^Webpage\.aspx$ /${mapfile:%1}? [NC,R=301,L]
Regards
Andrew
Re: friendly URL
Ok getting closer, this does rewrite it so that it is pretty http://www.mysite.com/Nutrition-info but I get a 404 because the page does not exist. Do I need a reverse mapfile as well to correspond to the existing page?
Thanks,
John
Thanks,
John
- HeliconAndrew
- Posts: 1264
- Joined: 07 Mar 2012, 10:16
Re: friendly URL
That's correct now you need reversemapfile and the rule that would rewrite back.
Regards
Andrew
- Code: Select all
RewriteMap revmapfile txt:revmapfile.txt
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond ${revmapfile:$1|NOT_FOUND} !NOT_FOUND
RewriteRule (.*) /Webpage.aspx?${revmapfile:$1} [NC,L]
Regards
Andrew
8 posts
• Page 1 of 1
Who is online
Users browsing this forum: No registered users and 16 guests