mod-rewrite

Combine “folder as GET parameter” and “subdomain as GET parameter”

。_饼干妹妹 提交于 2019-12-23 02:42:17
问题 I have a site that rewrites path after domain to a page GET parameter. ##REWRITING DIRECTORIES TO GET PARAMETERS RewriteBase / #Ignore all real directories (do not rewrite them) RewriteCond %{REQUEST_FILENAME} !-d #Also do not rewrite real files RewriteCond %{REQUEST_FILENAME} !-f #For everything else, index.php should fetch the proper content RewriteRule ^([^/]*)$ index.php?page=$1 [QSA,L] ##This means: #example.com/help #~becomes~ #example.com?page=help The site uses multiple languages and

Delete get variables and .php using htaccess

青春壹個敷衍的年華 提交于 2019-12-23 02:39:13
问题 I'm trying to solve some htaccess question and I'm not able to reach the solution. I have the following html: <a href="www.site.com/home.php?Idi="English">English</a> <a href="www.site.com/home.php?Idi="Française">Française</a> and the goal is that user just gets in its address bar: www.site.com/home/English or www.site.com/home/Française Obviously, the get variables should arrive to home.php to be processed. Also, the site has other pages with extension .php and I got delete each extension

How to make a better URL with .htaccess and multiple parameters?

空扰寡人 提交于 2019-12-23 02:39:11
问题 I have a very long a unfriendly URL an I'm looking to make SEO better for the site: http://www.site.com/sub-site/index.php?page=nameofpage&locale=en_EN I would like to have this instead: http:// www.site.com/sub-site/en/nameofpage all the URLS are hard coded in the links in the form of: <a href="index.php?page=nameofpage&locale=en_EN">link</a> What is the best way to achieve this with mod-rewrite? I find it particularly difficult to achieve: combining both parameters, page and locale Turning

Welcome page before WordPress (sub directory install)

我的梦境 提交于 2019-12-23 02:21:19
问题 I installed WordPress to a sub directory: example.com/wp I use a rewrite rule to serve WordPress from my root URI: example.com # BEGIN WordPress <IfModule mod_rewrite.c> RewriteEngine On RewriteBase / RewriteRule ^index\.php$ - [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.php [L] </IfModule> # END WordPress I want to provide a welcome page for project launch: example.com/welcome.html It will have a simple welcoming message and should

Rewrite subdomain

偶尔善良 提交于 2019-12-23 01:58:09
问题 Obviously a pretty simple question: how do I rewrite (value1).example.com/(value2) to /(value1)/(value2) I've tried a couple of things without success. Thank you in advance. 回答1: Try this rule: RewriteCond %{HTTP_HOST} ^([^/.]+)\.example\.com$ RewriteCond $1/%1 !^([^/]+)/\1$ RewriteRule ^/([^/]+)? /%1%{REQUEST_URI} [L] Some explanation: My previous suggestion caused an infinite recursion as the L flag causes a restart of the rewriting process with the new URL: Remember, however, that if the

Query regarding subdomain redirection in Zend Framework

好久不见. 提交于 2019-12-23 01:57:08
问题 I was looking for an approach using Zend Framework - similar to sites like bit.ly and tinyurl - where I can take a request to a subdomain and store the subdomain in a variable. For instance, a request to localhost/abcdef will return $s = abcdef. I'm not sure how to accomplish this in ZF, where a request to localhost/abcdef will return the init() of the abcdef controller. Thanks for all the help! 回答1: Just use a regex route. $routeitem = new Zend_Controller_Router_Route_Regex('(.*)', array(1 =

How to redirect source URL with query string by using redirectmap in Apache

浪尽此生 提交于 2019-12-23 01:56:25
问题 I need to migrate my old site URLs (ending with .aspx/asp and these are a few hundreds) to new site (ending with .jsp/servlets). We've opted to use RedirectMap and RedirectRule to implement this migration in Apache. The plain URLS are working fine. But case-sensitivity in the source URL is causing redirecting to a PAGENOTFOUND (For example, /magazine/Magazine.aspx?Id=4 is redirecting to PAGENOTFOUND instead of http://mydomain.com/advice/beauty ). Another issue is that it is unable to redirect

Dynamically configured virtual hosting

巧了我就是萌 提交于 2019-12-23 01:27:10
问题 Helo! I would like to prepare a dynamic virtual host for all subdomains that will be created in future using mod_rewrite. All subdomains would be configured prety much same way, so i thought of using dynamic VH configuration. I want my document root for each subdomain to be /home/user/public_html/subdomainName. I've tried with following configuration, but had no success: <VirtualHost xxx.xxx.xxx.xxx:80> # get the server name from the Host: header UseCanonicalName Off <Directory /home/user

redirect all files with .php extension

穿精又带淫゛_ 提交于 2019-12-23 01:18:08
问题 have this code in a htaccess file to hide the final php extension of each file RewriteEngine on RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME}\.php -f RewriteRule ^(.*)$ $1.php but now i want to redirect to another page if the user try to complete the extension. i tried this line after the script above but i get a 500 internal error RewriteRule \.php$ - [R=404] thanks ! 回答1: Have your rewrite rules like this: RewriteEngine on Options +FollowSymlinks -MultiViews

CSS and JS not loading with mod_rewrite

随声附和 提交于 2019-12-23 00:44:05
问题 I am using apache's mod_rewrite module to improve my URL structure(for one instance- www.mydomainname.com/user.php?u=somename ) to some fancy URL like www.mydomainname.com/user/somename . I have successfully achieved it until I got into this very bad situation of CSS and JS relative path issue. Whenever I open up www.mydomainname.com/user/somename , it loads successfully without CSS and JS with only text and basic HTML. I used chrome's "inspect element" feature, which help me to know the