I installed Drupal 7 on Wamp Server. I can't find any checkbox or link to enable clean URLs; I see only the Run the Clean URL Test button.
How can I enable clean URLs?
Drupal Answers is a question and answer site for Drupal developers and administrators. It only takes a minute to sign up.
Sign up to join this communityThe settings for the clean URLs are at admin/config/search/clean-urls.
That page shows the "Enable clean URLs" checkbox only when it is possible to enable them; when the server is not configured to support them, that page shows the following message:
Clean URLs cannot be enabled. If you are directed to this page or to a Page not found (404) error after testing for clean URLs, see the online handbook.
On an Apache server, and with the default settings used from Drupal, clean URLs work if:
The following directives are present in the Apache configuration file
AllowOverride All
AccessFileName .htaccess
Enable the mod_rewrite
module then restart the wampserver.
I think you can enable the mod_rewrite
from the quick launch icon. Right click and view open the apache modules menu and make sure the mod_rewrite
is enabled.
UPDATE:
Open the file httpd.conf
inside apache installation folder and edit the following line:
# AllowOverride controls what directives may be placed in .htaccess files.
# It can be "All", "None", or any combination of the keywords:
# Options FileInfo AuthConfig Limit
#
AllowOverride None
To be:
AllowOverride All
How I solved my problem:
Clean URLS:
Enable the mod_rewrite
with this command:
a2enmod rewrite
Then under /etc/apache2/sites-available edit the “default” file and replace Override None
with Override All
. This needs to be changed twice.
Restart Apache
Please enable rewrite_module for apache using wampserver interface.
To access it click on the green "w" icon in systray, go to apache > apache modules > click on rewrite_module.
your wampserver icon should turn red and then orange and green. If not try restarting wampserver. When the icon is green visit the apache modules again and ensure that rewrite_module is checked.
enabling rewrite_module is essentially turning on mod_rewrite, but dont know why wampserver calls it so. Hopefully it solves your issue with clean urls, you can verify its fixed by running the test again.
For cleaning URL open Terminal -> Type the command vim /etc/apache2/sites-enabled/000-default
It would open the 000-default file there you would see
<VirtualHost *:80>
ServerAdmin webmaster@localhost
DocumentRoot /var/www
<Directory />
Options FollowSymLinks
AllowOverride none
</Directory>
<Directory /var/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
</Directory>
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
<Directory "/usr/lib/cgi-bin">
AllowOverride None
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/access.log combined
Alias /doc/ "/usr/share/doc/"
<Directory "/usr/share/doc/">
Options Indexes MultiViews FollowSymLinks
AllowOverride None
Order deny,allow
Deny from all
Allow from 127.0.0.0/255.0.0.0 ::1/128
</Directory>
</VirtualHost>
So select the entire code and put this in place of the code in 000-default file.
<VirtualHost *:80>
ServerAdmin webmaster@localhost
DocumentRoot /var/www
<Directory />
Options FollowSymLinks
AllowOverride All
</Directory>
<Directory /var/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
</Directory>
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
<Directory "/usr/lib/cgi-bin">
AllowOverride None
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/access.log combined
Alias /doc/ "/usr/share/doc/"
<Directory "/usr/share/doc/">
Options Indexes MultiViews FollowSymLinks
AllowOverride None
Order deny,allow
Deny from all
Allow from 127.0.0.0/255.0.0.0 ::1/128
</Directory>
</VirtualHost>
Now restart the aparche server using
sudo service apache2 restart
You can use this by .htaccess
file
First find this line of code in .htaccess
file
#RewriteBase /
and replace it with following line of code:
RewriteBase /~yoursitename/yoursitename
Remove #
from the code. Here yoursitename
is the folder name after domain name like example.com/~yoursitename/yoursitename
.
We need to uncomment or add the line:
LoadModule rewrite_module modules/mod_rewrite.so
to enable mod_rewrite
Apache module.