. htaccess not working in server

痞子三分冷 提交于 2019-12-04 02:21:59

问题


Hi My web server is Apache.I have created a sample application in my local system. It's working fine with the clean url. But when i uploaded to my Web server( Apache) it's not working. Is there is any settings in Apache? If yes what are the steps? How can I check is mod_rewrite is enable in my Apache server? is it any way to know "mod_rewrite is on " through any PHP coding?

Thanks in advance


回答1:


Is there any way to know "mod_rewrite is on " through any PHP coding?

Yes, create a php page with <?php phpinfo(); ?>. This lists your server configuration. Under the apache2handler section in "Loaded Modules" you should see mod_rewrite if it is installed.

If it isn't listed there you will either need to ask your host or if you have access, see the apache modules-enabled folder (eg in /etc/apache2 on a standard installation) to see if there is a mod_rewrite listed.




回答2:


Most likely *mod_rewrite* is enabled. If it is not, you will probably need to contact your hosting company to activate it OR override the servers default with RewriteEngine On in your .htacces. Are you getting a 500, Internal Server Error when you try to run the script?

And if it was not compiled (or they can't provide it) with php, then maybe its time to find a new host?

Good luck!




回答3:


If you are using Apache on Ubuntu or DEBIAN write this code in Terminal:

sudo a2enmod rewrite

and restarting apache

sudo invoke-rc.d apache2 restart


来源:https://stackoverflow.com/questions/4709893/htaccess-not-working-in-server

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!