开发者

url in subfolder?

开发者 https://www.devze.com 2023-01-04 10:49 出处:网络
Please help me. How can 开发者_运维技巧I do for www.example.com/search.php?q=skipsoft to www.example.com/skipsoft? If you want to redirect everything you can do something like this in your .htaccess f

Please help me. How can 开发者_运维技巧I do for www.example.com/search.php?q=skipsoft to www.example.com/skipsoft?


If you want to redirect everything you can do something like this in your .htaccess file if you're using apache:

RewriteEngine On
RewriteRule ^(.*)$ /search.php?q=$1 [L,R]

But I would recommend something like this:

RewriteEngine On
RewriteRule ^/s/(.*)$ /search.php?q=$1 [L,R]

This will match www.yourdomain.com/s/author to www.yourdomain.com/search.php?q=author.


Without using JavaScript (which is a bad idea to modify the essential parts of a website, e.g. search), you won't be able to make forms submit data to a page that's not in the form /pagename?q=query or w/e.

But if you'd just like to shave of the .php extension, this will do the trick:

Options +FollowSymLinks
Options +Indexes
RewriteEngine on
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteRule ^([^\.]+)$ $1.php [NC,L]

In your .htaccess file, this will make it so that any file with a .php extension can be accessed without one.

0

精彩评论

暂无评论...
验证码 换一张
取 消