Apache is being a bitch. |
![]() ![]() |
Apache is being a bitch. |
![]()
Post
#1
|
|
![]() Mel Blanc was allergic to carrots. ![]() ![]() ![]() ![]() ![]() ![]() ![]() Group: Official Designer Posts: 6,371 Joined: Aug 2008 Member No: 676,291 ![]() |
So, I'm designing a website right now for a client. I put the website under a sub-directory under my own site with a sub-domain (for testing and all that jazz). Originally, it didn't have an .htaccess file so I uploaded it myself. I tried rewriting the URL by removing the trailing slash at the end of a URL with a directory (i.e. - replacing "http://test.domain.com/directory/" with "http://test.domain.com/directory"). So, after I uploaded the .htaccess file, this is what I used:
CODE <IfModule mod_rewrite.c> Options +FollowSymlinks RewriteEngine On RewriteCond %{HTTP_HOST} ^test.domain.com$ [NS] RewriteRule ^(.+)/$ http://%{HTTP_HOST}/$1 [R=301,L] </IfModule> This worked, kind of. When I tried going to "http://test.domain.com/directory/", it took me to "http://%{http_host}/directory" which, of course, the browser didn't recognize. So, I tried editing it again: CODE <IfModule mod_rewrite.c> Options +FollowSymlinks RewriteEngine On RewriteCond %{HTTP_HOST} ^(test.)?domain.com$ [NS] RewriteRule ^(.+)/$ http://%{HTTP_HOST}/$1 [R=301,L] </IfModule> Same issue. I tried again: CODE <IfModule mod_rewrite.c> Options +FollowSymlinks RewriteEngine On RewriteCond %{HTTP_HOST} ^(test.)?domain.com$ [NS] RewriteRule ^(.+)/$ http://test.domain.com/$1 [R=301,L] </IfModule> Same problem. I tried once more: CODE <IfModule mod_rewrite.c> Options +FollowSymlinks RewriteEngine On RewriteCond %{HTTP_HOST} ^test.domain.com$ [NS] RewriteRule ^(.+)/$ http://test.domain.com/$1 [R=301,L] </IfModule> Na-da. Finally, I just deleted the .htaccess file. And guess what? The rewrite rule was still doin' its thing, somehow. I tried using PHP to get my desired effect: CODE <?php if (substr($_SERVER['REQUEST_URI'], -1) == '/') { $uri = rtrim($_SERVER['REQUEST_URI'], '/'); header('Location: ' . $uri); } ?> No dice. Apache was still rewriting the URL somehow without the .htaccess file. So, I tried re-uploading the .htaccess file and this time, I used: CODE <IfModule mod_rewrite.c> Options +FollowSymlinks RewriteEngine On RewriteCond %{REQUEST_FILENAME}.php -f RewriteCond %{REQUEST_URI} !/$ RewriteRule (.*) $1\.php [L] RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.+)/$ /$1 [R=301,L] </IfModule> Nothing changed. Apache still rewrote the URL as "http://%{http_host}/directory". Mind explaining what went wrong and/or how I can fix it? Thanks By the way, "http://test.domain.com" doesn't exist, it's just a filler for y'all to understand what I'm gettin' at. |
|
|
![]()
Post
#2
|
|
![]() Mel Blanc was allergic to carrots. ![]() ![]() ![]() ![]() ![]() ![]() ![]() Group: Official Designer Posts: 6,371 Joined: Aug 2008 Member No: 676,291 ![]() |
Never mind, it seems like it was a problem with my web host.
This can be closed. |
|
|
![]()
Post
#3
|
|
![]() Senior Member ![]() ![]() ![]() ![]() ![]() ![]() ![]() Group: Administrator Posts: 8,629 Joined: Jan 2007 Member No: 498,468 ![]() |
Topic Closed and Moved
|
|
|
![]() ![]() |