mod-rewrite

url redirection working incorrect using .htacess in php

半世苍凉 提交于 2019-12-12 05:05:53
问题 I have one sub domain api.example.com. my code is on /var/www/html/ folder. my all sub domain is redirect to /var/www/html folder. I am use api.example.com to redirect on /var/www/html/api folder. Using .htaccess RewriteEngine On RewriteCond %{HTTP_HOST} ^api\. [NC] RewriteRule !^api/ api%{REQUEST_URI} [L,NC] But the problem is, it is also change my url , api.example.com/api i don't want to change my URL. when i type api.example.com in browser tab and press enter then it is change into the

mod_rewrite for removing .php extension is producing 404 error

与世无争的帅哥 提交于 2019-12-12 04:55:46
问题 I've looked up and tried 3 or 4 answers on SO for this and they are not working for me. I have dev.mydomain.com/pw/ and I want dev.mydomain.com/pw/builder to redirect to dev.mydomain.com/pw/builder.php etc. I have tried several solutions including: RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteRule (.*) $1.php [L] from: here and: RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME}.php -f

.htaccess doesn't work on VirtualHost

纵饮孤独 提交于 2019-12-12 04:54:04
问题 Since I've setup a wildcard VirtualHost my htaccess files does not work anymore The http-vhosts.conf NameVirtualHost * <VirtualHost *:80> ServerName default.dev VirtualDocumentRoot /Users/[UserName]/Sites/%-2 <Directory /Users/[UserName]/Sites/%-2> Options Indexes FollowSymLinks MultiViews AllowOverride All Order allow,deny allow from all </Directory> </VirtualHost> the .htaccess (WordPress default) <IfModule mod_rewrite.c> RewriteEngine On RewriteBase / RewriteRule ^index\.php$ - [L]

Redirecting Subdomain to WWW using .htaccess

荒凉一梦 提交于 2019-12-12 04:49:48
问题 I'm trying to redirect a specific subdomain to www. I already have rules in place that will redirect non-www to www.domain.com. Here is what I currently have, and it works fine: RewriteCond %{HTTP_HOST} !^www\. [NC] RewriteCond %{HTTP_HOST} ^([^.]+\.[a-z]{2,6})$ [NC] RewriteRule ^(.*)$ http://www.%1/$1 [R=301,L] My problem is that some requests are coming in for ns2.domain.com , and I would like those redirected to www.domain.com as well. Any help? 回答1: Try adding an extra [^.]+\. in your

.htaccess rewriting complex URL

核能气质少年 提交于 2019-12-12 04:49:16
问题 I have the following .htaccess containg some rules: Options +FollowSymLinks -MultiViews RewriteEngine On RewriteBase / RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s/+(.*?)(?:\+|%20|\s)+(.+?)\sHTTP [NC] RewriteRule ^ /%1-%2 [L,NE,R=302] RewriteRule ^([_&/A-Za-z0-9\s]+)-([&/A-Za-z0-9\s]+)-([&/A-Za-z0-9\s]+)-Photographers?$ html/photographers-10.cfm?county=$1&speciality=$2&address4=$3&rwtn [NC,L] RewriteCond %{QUERY_STRING} !rwtn RewriteCond %{QUERY_STRING} ^county=(.*)&speciality=(.*)&address4=(.*)

Redirecting /media/* to /project/media/* and everything else to /dispatch.php

≯℡__Kan透↙ 提交于 2019-12-12 04:47:57
问题 I have the following rewrite rules: <IfModule mod_rewrite.c> RewriteEngine on RewriteBase / # Route requests to /media/* to /projects/media/* RewriteRule ^media/.* - [NC,L] # Route all URLs to dispatch.php. RewriteRule ^(.*)$ dispatch.php [L] </IfModule> This redirects everything to dispatch.php, unless the URL is example.com/media/* in which case it will look for the requested file in ./media/ . I would like the URL /media/* to be rewritten to look in project/media/* . Using the rewrite rule

Rewrite rule index.php?/controller/method/param to /controller/method/param

拜拜、爱过 提交于 2019-12-12 04:44:48
问题 I need a rewrite rule for this url http://localhost/~user/frame/lib/index.php?/controller/method/12/22/ How can i rewrite it that i can call it like this http://localhost/~user/frame/lib/controller/method/12/22/ What is the rewrite rule for the above problem? I hope i could explain my question clear. 回答1: Try this rule: RewriteRule $2 !^index\.php$ RewriteRule ^(/~[^/]+/[^/]+/[^/]+)(/.*)? $1/index.php?$2 Depending on where you want to use this rule (my suggestion is meant for the server

Edit .htaccess on plugin deactivate

六眼飞鱼酱① 提交于 2019-12-12 04:37:07
问题 I am trying to add rewrite rules in .htaccess during plugin activation. How can I edit/roll-back rewrite rules in .htaccess on plugin deactivation? function add_to_htaccess( $rules ) { $content = <<<EOD \nAddOutputFilterByType DEFLATE text/plain AddOutputFilterByType DEFLATE text/html AddOutputFilterByType DEFLATE text/xml AddOutputFilterByType DEFLATE text/css AddOutputFilterByType DEFLATE application/xml AddOutputFilterByType DEFLATE application/xhtml+xml AddOutputFilterByType DEFLATE

error file .htaccess 500 Internal Server Error

烂漫一生 提交于 2019-12-12 04:35:44
问题 I have a problem with installing a php script coupon if load .htaccess file error page Internal Server Error The server encountered an internal error or misconfiguration and was unable to complete your request. Please contact the server administrator at webmaster@lefrasibelle.com to inform them of the time this error occurred, and the actions you performed just before this error. More information about this error may be available in the server error log. Additionally, a 500 Internal Server

How to rewrite these urls for country, state, city?

↘锁芯ラ 提交于 2019-12-12 04:35:23
问题 I have a site where articles being submitted from worldwide and I record the location of them as Country -> State -> City , for that I am generating URLs like: site/location/countryname/statename/cityname I have a single php file which can take care of coming request and gets values in query string, now the problem is how to write mod_rewrite so it can have URL like above? PS: It should not pass empty values if someone deletes the statename or countryname, means URL can be: site/location