I just moved from a dedicated server to a shared server to save money, but now my htaccess file doesn't work. I think its 1and1, but I'm not 100% sure. What the heck is wrong? Any ideas?

The single pages work:

RewriteRule ^internships/?$ internships.php [L]

but pages underneath them don't:

RewriteRule ^internships/([A-Za-z0-9_-]+)/?$ internships.php?p=$1 [L]

So if you go to mysite.com/internships it will bring you to the correct page, but if you go to internships/photography it won't.

htaccess file

AddType x-mapp-php5 .php

RewriteEngine on
RewriteBase /

RewriteCond %{HTTP_HOST} ^www.mySite\.com$
RewriteRule ^(.*)$ http://mySite.com/$1 [R=301,L]

RewriteRule ^casting-calls/?$ soon.php [L]
RewriteRule ^upgrade/?$ soon.php [L]

RewriteRule ^internships/([A-Za-z0-9_-]+)/?$ internships.php?p=$1 [L]
RewriteRule ^internships/?$ internships.php [L]

RewriteRule ^profile/mail/to-([A-Za-z0-9_-]+)/?$ mail.php?to=$1
RewriteRule ^profile/mail/(read|unread|sent)/?$ mail.php?view=$1 [L]
RewriteRule ^profile/mail/?$ mail.php [L]

RewriteRule ^privacy/?$ privacy.php [L]
RewriteRule ^terms/?$ terms.php [L]
RewriteRule ^contact/?$ contact.php [L]
RewriteRule ^advertising/?$ advertising.php [L]
RewriteRule ^membership/?$ membership.php [L]
RewriteRule ^forgot/?$ forgot.php [L]

RewriteRule ^admin/([a-z_]+)/?$ admin.php?m=$1 [QSA,L]
RewriteRule ^admin/?$ admin.php [L]

RewriteRule ^user/([A-Za-z0-9_-]+)/photos/([0-9]+)/?$ portfolio.php?username=$1&photo=$2 [L]
RewriteRule ^user/([A-Za-z0-9_-]+)/photos/?$ portfolio.php?username=$1 [L]
RewriteRule ^user/([A-Za-z0-9_-]+)/?$ user.php?username=$1 [L]
RewriteRule ^user/([A-Za-z0-9_-]+)/common-friends/([0-9]+)/?$ friends.php?username=$1&page=$2&common=1 [L]
RewriteRule ^user/([A-Za-z0-9_-]+)/common-friends/?$ friends.php?username=$1&common=1 [L]
RewriteRule ^user/([A-Za-z0-9_-]+)/friends/([0-9]+)/?$ friends.php?username=$1&page=$2 [L]
RewriteRule ^user/([A-Za-z0-9_-]+)/friends/?$ friends.php?username=$1 [L]

RewriteRule ^issues-([0-9]+)/?$ issues.php?issue=$1 [L]
RewriteRule ^issues/?$ issues.php [L]

RewriteRule ^join/(model|industry|agency|subscriber)/process-([0-9]+)/?$ join.php?type=$1 [L]
RewriteRule ^join/(model|industry|agency|subscriber)/?$ join.php?type=$1 [L]
RewriteRule ^join/?$ join.php [L]

RewriteRule ^profile/friends/(banned|requests)/([0-9]+)/?$ friends.php?mode=$1&page=$2
RewriteRule ^profile/friends/(banned|requests)/?$ friends.php?mode=$1
RewriteRule ^profile/friends/([0-9]+)/?$ friends.php?page=$1 [L]
RewriteRule ^profile/friends/?$ friends.php [L]
RewriteRule ^profile/photos/edit-profilepic/?$ portfolio.php?edit=profilepic [L]
RewriteRule ^profile/photos/?$ portfolio.php [L]
RewriteRule ^profile/experience/?$ profile-edit.php?m=experience [L]
RewriteRule ^profile/personal/?$ profile-edit.php?m=personal [L]
RewriteRule ^profile/resume/?$ profile-edit.php?m=resume [L]
RewriteRule ^profile/settings/?$ profile-edit.php [L]
RewriteRule ^profile/?$ profile.php [L]

RewriteRule ^profile/(.*) http://modelingintl.com/user/$1 [R=301,L]

RewriteRule ^voting/([A-Za-z0-9_-]+)-([0-9]+)/browse/(new|hot|results)/([0-9]+)/?$ voting.php?contest=$2&photo=$4&sort=$3 [L]
RewriteRule ^voting/([A-Za-z0-9_-]+)-([0-9]+)/browse/(new|hot|results)/?$ voting.php?contest=$2&photo=1&sort=$3 [L]
RewriteRule ^voting/([A-Za-z0-9_-]+)-([0-9]+)/browse/([0-9]+)/?$ voting.php?contest=$2&photo=$3 [L]
RewriteRule ^voting/([A-Za-z0-9_-]+)-([0-9]+)/browse/?$ voting.php?contest=$2&photo=1 [L]
RewriteRule ^voting/([A-Za-z0-9_-]+)-([0-9]+)/add/?$ voting.php?contest=$2&add=1
RewriteRule ^voting/([A-Za-z0-9_-]+)-([0-9]+)/(new|hot|results)/([0-9]+)/?$ voting.php?contest=$2&page=$4&sort=$3 [L]
RewriteRule ^voting/([A-Za-z0-9_-]+)-([0-9]+)/(new|hot|results)/?$ voting.php?contest=$2&sort=$3 [L]
RewriteRule ^voting/([A-Za-z0-9_-]+)-([0-9]+)/([0-9]+)/?$ voting.php?contest=$2&page=$3 [L]
RewriteRule ^voting/([A-Za-z0-9_-]+)-([0-9]+)/?$ voting.php?contest=$2 [L]
RewriteRule ^voting/vol([0-9]+)-iss([0-9]+)/([A-Za-z0-9_-]+)/?$ voting.php?vol=$1&iss=$2&network=$3 [L]
RewriteRule ^voting/vol([0-9]+)-iss([0-9]+)/?$ voting.php?vol=$1&iss=$2 [L]
RewriteRule ^voting/?$ voting.php [L]

RewriteRule ^search/([0-9]+)/?$ search.php?page=$1&view=1 [L]
RewriteRule ^search/([0-9]+)/(details|photos)/?$ search.php?page=$1&view=$2 [L]
RewriteRule ^search/(details|photos)/([0-9]+)/?$ search.php?page=$2view=$1 [L]
RewriteRule ^search/(details|photos)/?$ search.php?view=$1 [L]
RewriteRule ^search/?$ search.php?view=1 [L]

RewriteRule ^articles/([A-Za-z0-9_-]+)-([0-9]+)/?$ article.php?article=$2 [L]
RewriteRule ^articles/?$ contribute.php [L]
RewriteRule ^contribute/submit/?$ contribute.php?submit=1 [L]
RewriteRule ^contribute/([A-Za-z0-9\s_-]+)/([0-9]+)/?$ contribute.php?sfor=$1&page=$2 [L]
RewriteRule ^contribute/([0-9]+)/?$ contribute.php?page=$1 [L]
RewriteRule ^contribute/?$ contribute.php [L]

RewriteRule ^qna/([A-Za-z0-9_-]+)-([0-9]+)/?$ question.php?qna=$2 [L]
RewriteRule ^qna/([A-Za-z0-9\s_-]+)/([0-9]+)/?$ qna.php?sfor=$1&page=$2 [L]
RewriteRule ^qna/submit/?$ qna.php?submit=1 [L]
RewriteRule ^qna/([0-9]+)/?$ qna.php?page=$1 [L]
RewriteRule ^qna/?$ qna.php [L]

RewriteRule ^api/([A-Za-z0-9_-]+)$ api.php?m=$1 [QSA,L]
RewriteCond %{HTTP_USER_AGENT} wget [NC]
RewriteRule .* - [F] 

migrated from programmers.stackexchange.com Apr 18 '11 at 20:26

This question came from our site for professionals, academics, and students working within the systems development life cycle.

  • 1
    call 1and1 tech support to help you debug this – Steven A. Lowe Apr 18 '11 at 20:24
  • do you need a closing slash on /internships/photography/ ? I've noticed that with my rewrites. – dkuntz2 Apr 18 '11 at 22:36

Strange - I used to host on 1&1, and never had a problem with rewrites... but it doesn't sound like their support are being particular helpful.

First off - get them to confirm that mod_rewrite is enabled (the reason /internships may be working is because they enable mod_negotiation which looks for a best match if it doesn't find the correct one - so mod_negotiation is loading internships.php and not mod_rewrite).

A really quick check is if you access the site as www.mysite.com - do you get redirected to mysite.com? That should confirm it either way.

One thing though - can you make it clearer if mysite.com/internships/photography is directing you to internships or to a 404?


I never set the RewriteBase - I recommend disabling that, and placing a leading / in front of your RewriteRule patterns... maybe even try without the ^

Also, I suggest escaping the - and _ in your patterns: ([A-Za-z0-9_-]+)

  • I called 1and1 this morning and I was told that mod_rewrite is enabled by default, but I can't find it anywhere in the phpinfo() file. – user6944 Apr 19 '11 at 14:14
  • It did bring me to mysite.com after I tried www.mysite.com so I guess that part works. Its directed to a 404 error right now. It should be directing you to an internships template file, but its not... – user6944 Apr 19 '11 at 14:43
  • I think I'm going to move to a virtual hosted site if I can't get this error fixed. it might just be an issue with shared hosted packages. I just want to make sure before I sign another contract. – user6944 Apr 19 '11 at 16:42
  • It is not an issue with shared hosting - as I said, I did this when I was on 1&1 shared hosting. What apache modules are loaded? – HorusKol Apr 20 '11 at 0:01

Have you checked the file ownership and read/write permissions? Usually it's either that, or you're not allowing .htaccess overrides in your httpd.conf.

  • 1) I called 1and1 and they said that I have to put the files in their respective folders i.e. /internship/ folder. I'm going to call them again because I don't think the guy understood what an htaccess file is... 2) Also updated the permissions and that didn't fix it. 3) I don't have access to the httpd.conf file, but some of the redirects are working... i.e. internships/ – user6944 Apr 18 '11 at 22:18
  • 1and1 just said that they don't handle scripting and that I need to hire somebody who does. They won't tell me what the issue / differences are between the old dedicated and now shared host... – user6944 Apr 18 '11 at 22:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy