Friendly URL Help (Beginner)

Discuss practical ways rearrange URLs using mod_rewrite.

Friendly URL Help (Beginner)

Postby freews » Wed Apr 30, 2008 5:00 am

Hi,

How are the rules used in .htaccess to convert

this: www.example.com/example.php?x=1

in this: www.example.com/1

Thanks.
freews
 
Posts: 5
Joined: Wed Apr 30, 2008 4:52 am

Postby richardk » Thu May 01, 2008 1:14 pm

Try
Code: Select all
Options +FollowSymLinks

RewriteEngine On

RewriteRule ^([0-9]+)/?$ /example.php?x=$1 [QSA,L]
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am

Postby freews » Thu May 01, 2008 8:04 pm

I will try to do it.

thank you richardk.

richardk wrote:Try
Code: Select all
Options +FollowSymLinks

RewriteEngine On

RewriteRule ^([0-9]+)/?$ /example.php?x=$1 [QSA,L]
freews
 
Posts: 5
Joined: Wed Apr 30, 2008 4:52 am

Re: Friendly URL Help (Beginner)

Postby slobjones » Wed May 07, 2008 11:23 am

freews wrote:How are the rules used in .htaccess to convert

this: www.example.com/example.php?x=1

in this: www.example.com/1

I've got a question about this process, which is supposed to display static urls that are more friendly to search engines.

The rewrite doesn't actually result in the url displaying as example.com/1. It merely allows the url to be written that way.

The blog still produces the url as example.com/example.php?x=1, and search engines still index it that way.

We still have dynamic urls, and Google still doesn't like them. So what advantage is gained here?
slobjones
 
Posts: 32
Joined: Sat Dec 29, 2007 2:56 pm

Postby richardk » Wed May 07, 2008 2:50 pm

You are supposed to edit your script so that it does output the friendly URLs, then you might gain something. The mod_rewrite is only a small part of it.
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am

Postby slobjones » Wed May 07, 2008 9:55 pm

richardk wrote:You are supposed to edit your script so that it does output the friendly URLs, then you might gain something. The mod_rewrite is only a small part of it.

richardk, do you mean I should edit the blog script? As a user and not a programmer, that's not likely to happen.

But if I were able to edit the blog script so it output friendly urls, why would I need a mod rewrite?
slobjones
 
Posts: 32
Joined: Sat Dec 29, 2007 2:56 pm

Postby richardk » Sun May 11, 2008 1:15 pm

do you mean I should edit the blog script? As a user and not a programmer, that's not likely to happen.

Yes. Then you should ask the authors/community of the blog script if there is a friendly URL version/modification/plug-in or if anyone is willing to help you create one.

But if I were able to edit the blog script so it output friendly urls, why would I need a mod rewrite?

It depends on how you edit the script. Usually, editing the blog script makes it output the new URLs (the links would be friendly) but they would not work when clicked. Mod_rewrite would make the new URLs work.
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am

Postby TeckniX » Mon May 12, 2008 8:44 am

It would be nice if we could redirect a user to a certain url but send the search engine a redirect of a completely different form.

So you could have:

domain.com/example/more_stuff/my_item

The different folder levels would help to display the right page, yet the search engine would get a hard redirect/permanently moved for:

domain.com/my_item

That would be some sweeet mod-rewrite action!
TeckniX
 
Posts: 38
Joined: Tue Mar 27, 2007 12:18 pm

Postby richardk » Mon May 12, 2008 2:11 pm

It would be nice if we could redirect a user to a certain url but send the search engine a redirect of a completely different form.

That's more likely to harm your ranking than help it. URL Redirection, Manipulating Search Engines.

domain.com/example/more_stuff/my_item

The different folder levels would help to display the right page, yet the search engine would get a hard redirect/permanently moved for:

domain.com/my_item

To redirect /example/more_stuff/my_item to /my_item based on the user agent
Code: Select all
Options +FollowSymLinks

RewriteEngine On

RewriteCond %{HTTP_USER_AGENT} googlebot|slurp [NC]
RewriteRule ^example/more_stuff/my_item/?$ /my_item [R=301,L]
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am


Return to Friendly URLs with Mod_Rewrite

Who is online

Users browsing this forum: No registered users and 97 guests

cron