Five days ago my friend gave me a problem. Problem is bellow
His client gave him a job that fixing the broken link of the site.
That site use rewrite engine to rewrite the .html file to .php file. Also the server uses the virtual hosts.
We saw that the rewrite rules are correctly written and the expected files are present. But the link showed that internal server error and it didn’t find the file.
We have noticed that the server find the files in a directory. So we made a script to find the directory of that script, we have noticed that it is not the same directory. But we didn’t find any problem with the rewrite rules. here is the content of the .htaccess file
# enable mod_rewrite
RewriteEngine on
# correct urls for yahoo bot
RewriteCond %{REQUEST_URI} !\..+$
RewriteCond %{REQUEST_URI} !/$
RewriteRule (.*) %{REQUEST_URI}/ [R=301,L]
# mod_rewrite rules for ROOT category
RewriteRule ^index([0-9]+).html$ index.php?category=0&page=$1 [QSA,L]
# mod_rewrite rules for categories pages with HTML path option disable
RewriteRule ^(.*)/$ index.php?category=$1 [QSA,L]
RewriteRule ^(.*)/index([0-9]+).html$ index.php?category=$1&page=$2 [QSA,L]
# mod_rewrite rule for suggest listing page
RewriteRule report-listing.php$ report-listing.php [QSA,L]
RewriteRule ^([a-z]+)-listings.html$ listings.php?view=$1 [QSA,L]
RewriteRule ^([a-z]+)-listings([0-9]+).html$ listings.php?view=$1&page=$2 [QSA,L]
# mod_rewrite rules for view listing page
RewriteRule ^([^/]+)-l([0-9]+).html$ view-listing.php?cat=&title=$1&id=$2 [QSA,L]
RewriteRule ^(.*)/([^/]+)-l([0-9]+).html$ view-listing.php?cat=$1&title=$2&id=$3 [QSA,L]
# mod_rewrite rules for additional pages
RewriteRule ^p(.*).html$ page.php?name=$1 [QSA,L]
# mod_rewrite rules for error pages
RewriteRule ^([0-9]+).htm$ error.php?error=$1 [QSA,L]
# mod_rewrite rules for suggest category page
RewriteRule ^suggest-category-([0-9]+).html$ suggest-category.php?id=$1 [QSA,L]
RewriteRule ^LICENSE.htm$ LICENSE.htm [QSA,L]
# mod_rewrite rules for categories pages
RewriteRule ^(.*)_([0-9]+).html$ index.php?category=$1&page=$2 [QSA,L]
RewriteRule ^(.*).html?(.*)$ index.php?category=$1&$2 [QSA,L]
RewriteRule ^(.*).html$ index.php?category=$1 [QSA,L]
ErrorDocument 500 500.htm
ErrorDocument 404 404.htm
ErrorDocument 403 403.htm
ErrorDocument 401 401.htm
After that we made some .html file and put thats in the server and delete the .htaccess file to check that without rewrite rules it works or not. That works!!! So we became confirm that the problem is in rewrite rule.
But the rewrite rules is correct. So where is the problem??????
After googling we have found something about RewriteBase here.
Few days ago i have studied about the virtual hosts of apache, there i have found that the RewriteBase is can be configured for every virtual host. So that I think maybe we found the solution.
Then I have added just one line after the followings
# enable mod_rewrite RewriteEngine on #this line is addedd RewriteBase /
And the things work like a magic.
Have you got this problem before??? If so then what is your experience???
Apache RewriteBase Problem said
[...] Denker wrote an interesting post today onHere’s a quick excerptFive days ago my friend gave me a problem. Problem is bellow His client gave him a job that fixing the broken link of the site. That site use rewrite engine to rewrite the .html file to .php file. Also the server uses the virtual hosts. We saw that the rewrite rules are correctly written and the expected files are present. But the link showed that internal server error and it didn’t find the file. We have noticed that the server find the files in a directory. So we made a script to find the directory of that script, we have noticed that it is not the same directory. But we didn’t find any problem with the rewrite rules. here is the content of the .htaccess file [...]
Insufferably said
Somehow i missed the point. Probably lost in translation
Anyway … nice blog to visit.
cheers, Insufferably.
Jice said
Thank you for this post, i had the same problem
Problem said
How about changing to a theme that presents your webpage text in a legible font? The text in italics was far too small and I couldn’t be bothered to read it.
dynamyt said
The Magicwords are “physical path” and “alias”, see here
http://httpd.apache.org/docs/2.2/mod/mod_rewrite.html
Jimmy said
@Problem
Ctrl+ should solve your “problem”
sandrar said
Hi! I was surfing and found your blog post… nice! I love your blog.
Cheers! Sandra. R.
Faggot92 said
Its sale or reproduction is illegal except by public libraries, which may reproduce it for use in their in-house reading programs. ,
Sad92 said
Now if someone would just ask him how he came up with the utterly genius idea of drawing dog shit like soft serve ice cream! ,
Марк said
Фильмы онлайн,смотреть онлайн фильмы,фильмы онлайн бесплатно. Фильмы смотреть бесплатно онлайн,фильмы онлайн без регистрации,фильмы онлайн бесплатно без регистрации,смотреть фильмы онлайн без регистрации,онлайн фильмы качество,порно фильмы онлайн,онлайн фильмы хорошого качества,онлайн фильмы хорошего качества,смотреть онлайн фильмы в качестве,смотреть хорошие фильмы онлайн,смотреть фильмы онлайн хорошего качества,онлайн фильмы качество бесплатно,фильмы онлайн смотреть бесплатно качество