Jump to content

Mod_rewrite Working, But Not On New Host


son

Recommended Posts

I have an .htaccess entry to rewrite urls (to remove long querystrings) as:

Options +FollowSymlinksRewriteEngine OnRewriteRule ^services/([^/]+)\.php services.php?id=$1 [NC]RewriteRule ^services/([^/]+)/([^/]+)\.php services.php?p=$1&id=$2 [NC]

Works well on old server, but cannot make it work on one I move to. Running php info script on new hosting plan I can see under apache2handler the Apache version is: Apache/2.2.3 (CentOS) and mod_rewrite is listed under 'Loaded Modules'. I know that the old host runs PHP as a "CGI" module, so it won't display this in the phpinfo(). Do you have any ideas where I am going wrong? Both are obviously running Linux.Son

Link to comment
Share on other sites

Do .htaccess files work at all?By the way CGI stands for Common Gateway Interface and doesn't need to be placed in quotation marks.

Link to comment
Share on other sites

Do .htaccess files work at all?By the way CGI stands for Common Gateway Interface and doesn't need to be placed in quotation marks.
.htacces works well, have password-protection of folder I am testing on and works fine. What I just cannot get my head around: If my mod_rewrite rules work on one Apache server, could it be that it needs modification on a different Apache server or are the conditions themselves unique? If they are, it must be a permission problem or so (maybe they disabled it for shared solutions although it shows in PHP info - what do you think?). Otherwise, I have to delve deeper into mod_rewrite to see what I could change to make it work. The explanations on apache.org suggest to me that the syntax should work for any Apache server.With the staff of new host I am not getting anywhere yet, they seem to be short-staffed in technical personal due to festive periode which is fine in general, but bad as we wanted to go live on 5th of January...Son
Link to comment
Share on other sites

Try to test if mod_rewrite works. Like you say, they may have only enabled it globally (in .conf files that is), not for .htaccess files.Write a simple rewrite rule that works on a new file designed for testing. The PHP file (let's name it test.php):

<?phpvar_dump($_SERVER['REQUEST_URI'], $_SERVER['SCRIPT_NAME'], $_SERVER['QUERY_STRING']);?>

The .htaccess file:

RewriteEngine OnRewriteRule ^.+ test.php?$0

Try to accessexample.com/somethingandexample.com/somethingElseIf you get the same file with REQUEST_URI and QUERY_STRING changing, mod_rewrite should be working. If that's the case, tweak your rewriting rules a little to see if you can make them work.If it doesn't work (gives error 404), mod_rewrite is probably not enabled, but still, try to tweak my rule above a little to see if it will keep not working.

Link to comment
Share on other sites

It did not work, but can I just double-check I interpreted you correctly:It might be that one rule works well for one Apache server, but not for another Apache server?I would have hoped that it is the same for any Apache server....Son

Link to comment
Share on other sites

It did not work, but can I just double-check I interpreted you correctly:It might be that one rule works well for one Apache server, but not for another Apache server?I would have hoped that it is the same for any Apache server....Son
I'm saying mod_rewrite may not even be working at all for .htaccess and/or .htaccess may be disabled. Seeing it in phpinfo() is one thing, but making it work in .htaccss is another.That's what those tests are about. Verifying if .htaccess works, and if mod_rewrite is usable in it at all.
Link to comment
Share on other sites

I'm saying mod_rewrite may not even be working at all for .htaccess and/or .htaccess may be disabled. Seeing it in phpinfo() is one thing, but making it work in .htaccss is another.That's what those tests are about. Verifying if .htaccess works, and if mod_rewrite is usable in it at all.
.htacces works well, have password-protection of folder I am testing on via .htaccess. Cannot make mod_rewrite work, think they must have disabled it:-(Thanks for your help...Son
Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...