homepage Welcome to WebmasterWorld Guest from 54.81.170.186
register, free tools, login, search, subscribe, help, library, announcements, recent posts, open posts,
Subscribe to WebmasterWorld
Home / Forums Index / Code, Content, and Presentation / Apache Web Server
Forum Library, Charter, Moderators: Ocean10000 & incrediBILL & phranque

Apache Web Server Forum

    
rewrite on Go Daddy giving pain
rewrite on Go Daddy giving pain
drooh




msg:4446190
 8:07 pm on Apr 26, 2012 (gmt 0)

Ok, so with other hosts I do not have this issue. I've got some simple rules in place

RewriteEngine on
RewriteCond %{HTTP_HOST} ^experiencetejas.com$

RewriteRule ^([a-z0-9_-]+)$ /$1/ [R=301,L]
RewriteRule ^([a-z0-9_-]+)/$ /index.php?page_name=$1


However, because Go Daddy forces you to create sub domains in the same folder as the main site my rewite rules are taking affect on the sub domain, which is not what I want.

I tried to write the condition in there but it does not seem to help. I've already spent about an hour trying to figure this out but not really getting anywhere. Does anyone have a suggestion on how to only make the write rule apply to the main site and not the sub domains? Also, I am not using www in front, just http://

 

g1smd




msg:4446207
 8:55 pm on Apr 26, 2012 (gmt 0)

There's multiple problems with your rules.

Literal periods in patterns should be escaped.

The redirect target should contain the protocol and domain name.

The internal rewrite should include the [L] flag.

Why are you adding a slash to the URLs for pages? URLs ending with a slash are for folders.

Add a blank line after each RewriteRule so you can clearly see what code is grouped together.

drooh




msg:4446216
 9:05 pm on Apr 26, 2012 (gmt 0)

Do you mean like this
RewriteCond %{HTTP_HOST} ^http://experiencetejas\.com$ [L]

as for slashes i like all the URLs to look like website.com/about/ and not website.com/about

g1smd




msg:4446233
 9:28 pm on Apr 26, 2012 (gmt 0)

Use a trailing slash only when the URL is for a folder or the index page in a folder.

Make sure too that you use URLs beginning with a leading slash in the links to other pages of your site.

drooh




msg:4446242
 9:53 pm on Apr 26, 2012 (gmt 0)

can you comment on this
RewriteCond %{HTTP_HOST} ^http://experiencetejas\.com$ [L]

drooh




msg:4446252
 10:00 pm on Apr 26, 2012 (gmt 0)

whenever I put the [L] in there I get a 500 Internal server error, also I need to remind you this is only happening on Godaddy shared hosting

g1smd




msg:4446260
 10:07 pm on Apr 26, 2012 (gmt 0)

The [L] flag belongs on the RewriteRule that will follow the RewriteCond, not on the RewriteCond itself.

Add a blank line after each RewriteRule in order to make the code clearer to read.

drooh




msg:4446268
 10:16 pm on Apr 26, 2012 (gmt 0)

Well I've been fooling with this all day and I can not get it to work. Simply put, the rewrite is affecting admin.website.com and I dont want it to!

Again, here is where I am

RewriteEngine on

RewriteCond %{HTTP_HOST} ^(www\.)?experiencetejas\.com$ [NC]

RewriteRule ^([a-z0-9_-]+)$ /$1/ [R=301,L]

RewriteRule ^([a-z0-9_-]+)/$ /index.php?page_name=$1 [NC,QSA]

g1smd




msg:4446295
 11:13 pm on Apr 26, 2012 (gmt 0)

The redirect target should contain the protocol and domain name.

The internal rewrite should include the [L] flag.

lucy24




msg:4446298
 11:19 pm on Apr 26, 2012 (gmt 0)

RewriteCond %{HTTP_HOST} ^experiencetejas.com$

RewriteRule ^([a-z0-9_-]+)$ /$1/ [R=301,L]
RewriteRule ^([a-z0-9_-]+)/$ /index.php?page_name=$1

I have to say this line-spacing makes me uneasy. It makes it look as if you expect the Condition to apply to both of the following Rules. For clarity, it should be

RewriteCond %{HTTP_HOST} ^example.com$
RewriteRule ^([a-z0-9_-]+)$ /$1/ [R=301,L]

RewriteRule ^([a-z0-9_-]+)/$ /index.php?page_name=$1

... plus all other appropriate changes to the Rules themselves as laid out in g1's posts.

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / Apache Web Server
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About
© Webmaster World 1996-2014 all rights reserved