Page 2 of 4
Posted: Mon Mar 05, 2007 6:58 pm
by RobertGonzalez
Can you do a
to see if the module is on the system?
Posted: Mon Mar 05, 2007 7:46 pm
by Bill_VA
Wow, I didn't know I could do that (I told you I was new to Linix).
I found it in two places:
/usr/lib/apache2-prefork/mod_rewrite.so
/usr/lib/apache2/mod_rewrite.so
mod_rewrite doesn't appear anywhere in the httpd.conf file.
Posted: Mon Mar 05, 2007 10:15 pm
by RobertGonzalez
Now you need to look for a directory called conf.d. It is usually in /etc/httpd. Typically it will contain several .conf files, one of which would be the one that includes the mod_rewrite module. Before it is parsed though, apache needs to know the path of the modules directory, which will be in httpd.conf.
Keep in mind that I am very used to Red Hat systems, and this file structure could very easily be different than yours. If you do a find for \*httpd\* or \*apache\* or do a whereis httpd, it might tell you where everything is on your system as it relates to apache. Another thing you can do is find httpd.conf.
Posted: Tue Mar 06, 2007 8:19 am
by Bill_VA
I think I'm getting closer.
I have a file called loadmodule.conf in the /etc/apache2/sysconfig.d folder that lists the modules to load and "LoadModule rewrite_module /usr/lib/apache2-prefork/mod_rewrite.so" was not in the list.
There is a file in /etc/sysconfig/apache2 that lists all the modules to load on line 97, but rewrite wasn't in the list. I added it, restarted Apache and now mod_rewrite is in the loadmodule.conf file.
But I still get a 404 error no matter what I do to the .htaccess file. What am I doing wrong?
Posted: Tue Mar 06, 2007 10:36 am
by RobertGonzalez
Post your entire .htaccess file so we can review it.
Posted: Tue Mar 06, 2007 11:19 am
by Bill_VA
Here's what I have in my .htaccess file:
Code: Select all
RewriteEngine On
RewriteRule ^([A-Za-z0-9]+)/([A-Za-z0-9]+)/([A-Za-z0-9]+)$ /mysite/index.php?city=$1&page=$2&function=$3 [NC]
The .htaccess file is not in the server root, it's in a folder named "mysite" (/srv/www/htdocs/mysite/.htaccess)
I've tried it all sorts of ways:
RewriteRule ^([A-Za-z0-9]+)/([A-Za-z0-9]+)/([A-Za-z0-9]+)$ /index.php?city=$1&page=$2&function=$3 [NC]
RewriteRule ^([A-Za-z0-9]+)/([A-Za-z0-9]+)/([A-Za-z0-9]+)$ index.php?city=$1&page=$2&function=$3 [NC]
RewriteRule ^([A-Za-z0-9]+)/([A-Za-z0-9]+)/([A-Za-z0-9]+)$ index.php [NC]
RewriteRule ^mysite([A-Za-z0-9]+)/([A-Za-z0-9]+)/([A-Za-z0-9]+)$ /mysite/index.php?city=$1&page=$2&function=$3 [NC]
Posted: Tue Mar 06, 2007 11:39 am
by RobertGonzalez
Ok, before you get too far into this, try this...
Code: Select all
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^(.*)$ /mysite/test.html [QSA,L]
</IfModule>
Make a file called test.html and give it this code:
Code: Select all
<html>
<head>
<title>This is a rewrite test</title>
</head>
<body>
This is a rewriter test.
</body>
</html>
Before testing, make sure in your httpd.conf setup that the following are in either the main <Directory /> tag or in the <Directory> tag of the virtual host you are testing (if you do not know what a virtual host is, then you are probably not using one locally).
Code: Select all
<Directory />
Options FollowSymLinks
AllowOverride All
</Directory>
If you change the httpd.conf, restart apache, then try to go to your development site /sometext/ and it should show the url as yoursite /sometext but load the test.html page. If it doesn't, there are problems that may not be associated with your rewrite rules.
Posted: Tue Mar 06, 2007 12:07 pm
by Bill_VA
I gotta tell you Robert, this is getting frustrating, I'm glad you're there helping.
Still just a 404 error, I had to add the "Options FollowSymLinks" part to the <Directory> tag in the httpd.conf file, I restarted Apache, and still nothing.
Posted: Tue Mar 06, 2007 12:59 pm
by RobertGonzalez
Ok, what URL are you navigating to? even if it is localhost, please post the entire URL.
Posted: Tue Mar 06, 2007 1:14 pm
by Bill_VA
Posted: Tue Mar 06, 2007 1:31 pm
by RobertGonzalez
So given that, you should have pages for the site 'mysite' living in the Document root for that server. If you are hitting it with localhost or 127.0.0.1, the you are using the default server root and document root (unless you set up local virtual hosts, which I am assuming you didn't), so your directory structure for the location of these files is something like
In that mysite folder you should have a .htaccess file, and at the very least a test.html page. Am I correct at this point?
Posted: Tue Mar 06, 2007 1:42 pm
by Bill_VA
That is correct, I have the .htaccess file in the /mysite folder. No virtual host (I don't even know how to do it).
The directory stucture looks like:
Code: Select all
/
|
/srv
|
/www
|
/htdocs (this is the server root)
|
/mysite (the root for this site)
.htaccess
test.htm
index.php
Posted: Tue Mar 06, 2007 2:08 pm
by RobertGonzalez
Is the test page .htm or .html? Also, is it the same in the .htaccess file as it is in real life?
Posted: Tue Mar 06, 2007 2:12 pm
by Bill_VA
It's all .htm, I got in the habit many years ago of just using .htm instead of .html. The .htaccess file matches
Posted: Tue Mar 06, 2007 2:21 pm
by RobertGonzalez
Call test.htm directly. Does it load?