Clean URL's not working, mod_rewrite module in

2019-05-13 22:54发布

I just installed a fresh copy of Drupal 6.19 to get to speed on how to write modules. But for some reason the rewrite module isn't working for Drupal.

What I have checked:

  • $ apachectl -M >> it is installed
  • php_info() on current server >> says rewrite is installed also
  • I also double-checked the .htaccess file in my Drupal root folder
  • UPDATE: checked httpd.conf for AllowOverride All

I'm out options here. Looked everywhere but the Drupal settings aren't letting me to enable the settings and their test is simply visiting a site that should work if the rewrite module was there.

My specs: Mac OS X 10.6 Snow Leopard Using built-in Apache with PHP5

Thanks!

8条回答
爱情/是我丢掉的垃圾
2楼-- · 2019-05-13 23:31

As Álvaro G. Vicario mentioned, the first thing to do is at the top of the .htaccess file add something like ghfdiddfdjf which should throw an internal error. If it doesn't, you know the .htaccess file isn't being read. Mine wasn't, and I found the following fix:

In the etc/apache2/sites-enabled folder, there was a file called default-000. It was in this file that I changed AllowOverride All in 2 places in the file.

查看更多
倾城 Initia
3楼-- · 2019-05-13 23:32

Two more things to check:

  1. Verify that your .htaccess is readable for your apache processes (Yes, I read that you double checked it, but did that include the file permissions?)
  2. Enable rewrite logging - this might give you some hints on where it fails. Start with a log level of 5 and increase/decrease as needed. (Don't forget to turn it off again later, as it is a huge performance hog ;)

Also, I'd try to simplify the test scenario - start with a simple rewrite directive in a vhost configuration. Once that works, move it to a .htaccess in the top-level of the vhosts document root, then to sub directories (if needed/used).

查看更多
来,给爷笑一个
4楼-- · 2019-05-13 23:32

If you running your Drupal installation in a sub-folder like: example.com/drupal, then enable "RewriteBase /" in your .htaccess file, it might help you.

查看更多
女痞
5楼-- · 2019-05-13 23:33

Look for this Line in your httpd.conf file

#LoadModule rewrite_module modules/mod_rewrite.so

If commented Just uncomment it restart apache server then try enabling in drupal administer Clean URL Section

查看更多
家丑人穷心不美
6楼-- · 2019-05-13 23:33

I added the following to my .htaccess file and it was solved. My problem was specifically hapening with Rackspace / CentOS image

Options -MultiViews

查看更多
▲ chillily
7楼-- · 2019-05-13 23:48

Last but not least, you must authorize your virtual host or directory to use .htaccess.

AllowOverride All

Update:

I can't figure out your exact problem but it's always worth testing that Apache is actually parsing your .htaccess file. Make a syntax error on purpose and see if you get a 500 Internal Server Error message. Also, test mod_rewrite with a simple redirection rule that doesn't involve Drupal.

查看更多
登录 后发表回答