Make url pretty with .htaccess

给你一囗甜甜゛ 提交于 2019-12-02 07:33:10

The following should do what you ask. In addition to excluding files, it also excludes directories.

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ http://www.example.com/search.php?q=$1 [R,L]

This article has some good information if you want to learn more about clean URLs.

Below are a few more resources if you want to learn more about .htaccess. Usage of this file is fairly complex. Once you know what it is capable of, I recommend you search on Google for the features you need, when you need them. There are a lot of things it does that you may never need.

  1. more .htaccess tips and tricks..
  2. Ultimate Htaccess File Sample
  3. URL Rewriting Guide
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!