Forum Moderators: phranque

Message Too Old, No Replies

.htaccess dinamic to static

         

regix

3:22 pm on Jan 29, 2004 (gmt 0)

10+ Year Member



Hi,

I have a dynamic site that look like this.

[example.com...]

I don't have access to htpd it's a shared hosting, i have to do the rewrite only with .htaccess files.

The url static needs to be as short as possible

Thanks for your help,

RonPK

4:34 pm on Jan 29, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hi regix, welcome to WebmasterWorld!

Your question has been posted many times before, so if you do a site search (or Google) for something like 'mod_rewrite friendly url' something good should come up.

Feel free to post any problems that may occur!

jdMorgan

6:07 pm on Jan 29, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



regix,

Welcome to WebmasterWorld [webmasterworld.com]!

This search [google.com] should get you started nicely.

Jim

regix

2:25 pm on Jan 30, 2004 (gmt 0)

10+ Year Member



Hi,

I looked a rewrite rule generator of webmaster toolkit, but don't work. Is my host? The rule is wrong? is very difficult to say.

Options +FollowSymLinks
RewriteEngine on
RewriteBase /
RewriteRule en(.*)-(.*)-(.*)\.htm$ /directory/view\.php?site=$1&bn=$2&key=$3

I have place a .htaccess file in main directory with this rule and didn't work.

Suggestions?

jdMorgan

6:12 pm on Jan 30, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



regix,

There is an error in that code. Do not "escape" periods in the substitution string by preceding them with "\". Only periods in the pattern should be escaped:


Options +FollowSymLinks
RewriteEngine on
RewriteBase /
RewriteRule en(.*)-(.*)-(.*)\.htm$ /directory/vie[b]w.p[/b]hp?site=$1&bn=$2&key=$3

If you request "http://www.example.com/enAA-BB-CC.htm" from your server, this code will serve "http://www.example.com/directory/view.php?site=AA&bn=BB&key=CC"

I would suggest the following changes, but they are not needed for the code to work. They are only minor improvements:


Options +FollowSymLinks
RewriteEngine on
RewriteBase /
RewriteRule en([b][^-]*)-([^-]*)-([^.]*[/b])\.htm$ /directory/view.php?site=$1&bn=$2&key=$3 [b][L][/b]

Ref:
Apache mod_rewrite documentation [httpd.apache.org]
Regular Expressions tutorial [etext.lib.virginia.edu]

Jim

regix

12:51 am on Feb 1, 2004 (gmt 0)

10+ Year Member



Hi,

I changed the rule and didn't work.

The .htaccess file only have this 4 only or i have missed something to put inside.

I asked my host and it have mod_rewrite enabled.

When I go to url that needs to be rewrited i obtain the url unchanged.

Thanks,

jdMorgan

2:54 am on Feb 1, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



regix,

When I go to url that needs to be rewrited i obtain the url unchanged.

So, if you request "http://www.example.com/enAA-BB-CC.htm" from your server, you do not get the content you expect from "http://www.example.com/directory/view.php?site=AA&bn=BB&key=CC"?

Understand that mod_rewrite can only do this function - It cannot change the links that your script outputs. If you wish to change those links, you will have to modify your script.

Jim

regix

1:12 pm on Feb 13, 2004 (gmt 0)

10+ Year Member



Hi,

I rewrited all the url in my pages, but there aren't indexed.

I need to add something more the get pages indexed?

Thanks,

jdMorgan

7:40 pm on Feb 13, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You'll need to allow at least 30 days for search engines to crawl your site, detect the changes, and update their listings. For some second-tier search engines, it may take up to a year.

Jim