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 example.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.example\.com$
RewriteRule ^(.*)$ http://example.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] 
  • 1
    call 1and1 tech support to help you debug this
    – Steven A. Lowe
    Apr 18, 2011 at 20:24
  • do you need a closing slash on /internships/photography/ ? I've noticed that with my rewrites.
    – dkuntz2
    Apr 18, 2011 at 22:36

3 Answers 3


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.example.com - do you get redirected to example.com? That should confirm it either way.

One thing though - can you make it clearer if example.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:

  • 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, 2011 at 14:14
  • It did bring me to example.com after I tried www.example.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, 2011 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, 2011 at 16:42
  • 1
    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, 2011 at 0:01
  • "because they enable mod_negotiation" - this is most certainly the issue here +1 (or rather MultiViews - part of mod_negotiation) - despite the lack of information in the question about the current outcome. There is no problem with RewriteBase here, although it would seem to be unnecessary. You should NOT prefix the RewriteRule pattern with / - that will cause the match to fail in a .htaccess context. You also do not need to escape the - and _ in the regex character class. See my answer for more info.
    – MrWhite
    Apr 10, 2021 at 13:13

This is most certainly due to MultiViews (part of mod_negotiation) being enabled at the shared host. It is disabled by default on Apache (so your directives "work" on your dedicated server), but some shared hosting platforms do explicitly enable this for some reason. (It makes extensionless URLs "just work" out of the box but can potentially result in SEO/security issues if you are not expecting it and often results in conflicts with mod_rewrite - as in this case.)

MultiViews basically enables extensionless URLs. When you make a request that does not map directly to a file (eg. /internships), it looks in that directory for files that match the basename requested but with a file extension that would return the appropriate mime-type, eg. /internships.php returns a text/html response.

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

So, with MultiViews enabled, a request for /internships/photography results in an internal subrequest for /internships.php/photography without any query string parameters. /photography is passed through as path-info to the internships.php script. But since your script is looking for a p URL parameter, it fails to respond appropriately.

MultiViews is processed before mod_rewrite is able to match the requested URL-path, so your RewriteRule directive is effectively bypassed - since the pattern fails to match the request after MultiViews has "messed it up"!

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

Incidentally, the same applies here as well. When MutliViews is enabled this directive is not actually doing anything. But in this case, the output from MultiViews happens to be what you are expecting.

Disable MultiViews at the top of your .htaccess file:

Options -MultiViews


RewriteCond %{HTTP_USER_AGENT} wget [NC]
RewriteRule .* - [F]

"Blocking" directives should really be at the top of the .htaccess file, not at the end. Although, as it happens, it shouldn't make any difference in this instance. But it is more optimal to block early, rather than late (less load on your server).

RewriteRule ^profile/mail/to-([A-Za-z0-9_-]+)/?$ mail.php?to=$1

Several of your rules are missing L flags. Although, after a quick glance through the file, this again shouldn't really matter in this instance, however, it does mean the later directives are processed unnecessarily. So, it would be more optimal to include the L flag on all rewrites here.


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, 2011 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, 2011 at 22:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.