mod-rewrite

htaccess RewriteRule problem

我的梦境 提交于 2019-12-24 10:37:22
问题 I have a problem with RewriteRules. I'm currently using this rule: RewriteRule ^([^/.]+)/?$ index.php?clip=$1 This works fine for links as these, where $_GET['clip'] is the value after the slash: http://example.com/abcdefg But not for those with a dot character, like these: http://example.com/abcdefg.png How should I change the RewriteRule to make it work for such links? 回答1: RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^([^/]+)/?$ index.php?clip=$1 i

.htaccess RewriteRule trouble

蓝咒 提交于 2019-12-24 10:36:29
问题 I am guessing this question has been asked many times, but i could not find one that would perhaps give me what I need. So.. I can access the scripts by the following url's: http://website.com/index.php/hello/world http://website.com/hello/world Both go to index.php which parses the input (hello/world in this example). this is my .htaccess : <IfModule mod_rewrite.c> Options +FollowSymlinks RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule (.*

How to use RewriteRule like WordPress and Drupal

牧云@^-^@ 提交于 2019-12-24 10:33:28
问题 I have a website with an include script that will have a various number of variables. Here are some of the types of URLs and variables: Main page: index.php Login page: login.php (redirects to index.php after login). Logout page: logout.php (redirects to login after logout). Profile page: index.php?id=profile Users password page: index.php?id=profile&sub=password And some pages even has more variables in the URL. I want to use RewriteRules to be able to get nice URLs like this: url.com/my

Mod Rewrite Directory Checking

馋奶兔 提交于 2019-12-24 10:28:44
问题 I have a situation where I have several clients, each of which I'd like to be able to access their site via mydomain.com/clientname. To keep things organized, I store the actual files for the client's sites in /client/clientname. I can achieve the desired effect by putting lots and lots of these lines in my .htaccess: RewriteRule ^client1(.*)$ /client/client1$1 [L] RewriteRule ^client2(.*)$ /client/client2$1 [L] etc. I'm trying to do this in a cleaner way, by checking if the client directory

Url rewrite subfolder to root and forbid accessing subfolder

假如想象 提交于 2019-12-24 10:12:11
问题 I have drupal installed in a subfolder drupal , but I want to access pages as it is in root folder: http://www.example.com instead of http://www.example.com/drupal I'm able to have this working, but it's also working with url containing subfolder, so I have http://www.example.com and a clone site in http://www.example.com/drupal What is the rule to forbid access to subfolder? I want all url starting with http://www.example.com/drupal being forbidden. This is .htaccess in / directory: Options

In .htaccess, how to redirect non-lowercase versions of hostname

青春壹個敷衍的年華 提交于 2019-12-24 09:58:04
问题 In .htaccess on Apache2, how do you redirect all capitalization variations of a hostname to a canonical lowercase version, via 301 redirect, and keeping the rest of the path unharmed. Subdomains (or not) should do the same as well. Additionally, accessing via an IP should not redirect. examples: http://Example.com/foo => http://example.com/foo http://A.example.com/foo => http://a.example.com/foo http://A.EXample.com/foo?bar => http://a.example.com/foo?bar http://208.67.222.222/foo => http:/

URL Rewriting invisibly - How to prevent rewritten URL to appear in the address bar?

谁都会走 提交于 2019-12-24 09:48:15
问题 I have browsed the other topics, including this one: Mod_rewrite invisibly: works when target is a file, not when it's a directory, but I can't find a solution to my problem. I have the following rewriting rule: RewriteRule ^([a-zA-Z0-9_-]+)$ ./index.php?s=$1 [L,NC] RewriteRule ^([a-zA-Z0-9_-]+)/$ ./index.php?s=$1 [L,NC] What it does is to write anything like http://myaddress/parameter to http://myaddress/index.php?s=parameter and show this new rewritten address in the browser's address bar.

Using .htaccess to change directory show in url

这一生的挚爱 提交于 2019-12-24 09:28:25
问题 I am trying to change the url that show in the addressbar. Code in .htaccess: RewriteEngine On # Turn on the rewriting engine RewriteRule ^Home?$ index.php [NC,L] RewriteRule ^about-us?$ aboutus.php [NC,L] RewriteRule ^contact?$ contact.php [NC,L] RewriteRule ^products?$ products.php [NC,L] RewriteRule ^products/led-bulb?$ led-bulb.php [NC,L] Explain: All page in the same directory and 4 first rewrite rule is ok, but the last rewrite rule has problem.(products/led-bulb directory not exist).

Hide Part of URL htaccess

半世苍凉 提交于 2019-12-24 09:28:18
问题 The Goal: The user lands on the site where the latest 10 articles are shown (no problem here). The user clicks on the title of one article using this href link in a table: <a href='"."article.php/".$type."/".$id."/".$web_title."'>".$title."</a> All links from any $type get directed to article.php . article.php should be built dynamically based on the $id retrieving information from the database. I've got this URL rewrite in my htaccess file: RewriteEngine On RewriteCond %{REQUEST_URI} ^

Redirect “mydomain.com/user” to “mydomain.com/name.php?id=user”

笑着哭i 提交于 2019-12-24 09:17:37
问题 I think I can use the .htaccess file for this, but I've looked it up and not found anything useful. What I want to do is have my site redirect to a php page when a user types their username in the URL like: example.com/username And have it be the same as a PHP page like: example.com/name.php?id=username I'd like it to display as example.com/username even after it redirects, but it is not necessary. Any ideas? 回答1: You can use mod_rewrite to transparently rewrite your URLs on the server.