mod-rewrite

URL rewriting, PHP templating and the $_GET array

本小妞迷上赌 提交于 2019-12-22 17:38:09
问题 I have an index.php file in the top level with other files such as "login.php", "register.php" in a folder called includes. The folder hierarchy looks like this: index.php includes/ register.php login.php css/ style.css images/ image.png How can I set the url to something like http://www.mydomain.com/register which then from within the index.php page calls (includes) the register.php page? Is this the best way to go about it? Thanks Mike 回答1: If your server is Apache: Create on root folder

Redirect Subdomain to new domain

人盡茶涼 提交于 2019-12-22 15:11:28
问题 Hi guys trying to get a 301 redirect working and having trouble. I need to redirect sub.domain1.com to www.domain2.com and make sure that any file names or parameters get sent over with it. This is what I was trying: RewriteCond %{HTTP_HOST} ^domain1.com [NC] RewriteRule ^(.*)$ http://www.domain2.com/$1 [L,R=301] I also tried this: RewriteCond %{QUERY_STRING} ^$ RewriteRule ^sub\.domain1\.com$ /www.domain2.com? [R=301,NE,NC,L] Where am I messing up? 回答1: Rule of thumb for rewriterules: from

Yii removing application directory name from URL

拥有回忆 提交于 2019-12-22 14:06:41
问题 Okay seems like this is a pretty common problem, but I can't find a definitive solution on the forums. My Yii is set up like this /webroot/framework /webroot/app /webroot/requirements The app folder hosts the yii application however my url looks like : site[dot]com/app/site/index How do I remove the 'app' portion from the URL. I tried moving my .htaccess file to the webroot folder and it redirects but 'app' still shows up in the url Here are the contents of /webroot/.htaccess <IfModule mod

redirect without changing url

天涯浪子 提交于 2019-12-22 14:01:12
问题 I always suck at .htaccess I'm trying to have a website where all requests go though index.php but i'd like the URL to be like www.sample.com/home. effectively that url would load www.sample.com/index.php?page=home Right now I have RewriteRule ^/([a-z0-9-]+) /index.php?page=$1 [NC,PT,L] Which doesnt work even though regexr test shows it should. I temporarily changed it to r=301 so i could see the redirect and noticed that www.sample.com/home is redirecting to www.sample.com/index.php?page=

redirect subdomain to same subdomain name but different domain name

馋奶兔 提交于 2019-12-22 12:54:11
问题 i have site called exmaple.com have a lot of subdomains test1 , test2 , test2.example.com how could i redirect subdomains with exact subdomain but to another domain name for example test1 , test2 , test3.example.net thanks 回答1: This may work. Put it in your .htaccess. RewriteEngine On RewriteCond %{HTTP_HOST} (.*).example.com RewriteRule (.*) http://%1.example.net/$1 [R=301,QSA,L] Haven't tested it, but it should give you a start. 回答2: Use %1 %2 etc. to grab regex-match groups from the

.htaccess: “redirect permanent” with fallback to a “RewriteRule”

一世执手 提交于 2019-12-22 12:43:39
问题 i have a webshop where we switch the subdirectory. From "/shop" to the root "/". Also some Product- and category-names change. I want to redirect some specific URLs to newer ones. For Example: www.domainname.de/shop/product_abc to www.domainname.de/product_abc_v2 For this, I use the Redirect Permanent declaration in the .htaccess File. In the next Step I want a Fallback for all other URL´s which looks like this: www.domainname.de/shop/XXXXX . So i write this Rewrite Rule: RewriteCond %

Apache mod_rewrite RewriteRule incorrectly adding in port AWS

江枫思渺然 提交于 2019-12-22 12:26:23
问题 I have an issue where we are running two systems on the same EC2 instances and using AWS Elastic Load Balancer to send request for one systems to port 81. So for example we have www.example.com and bookings.example.com where the AWS Elastic Load Balancer sends requests for bookings. though to our EC2 boxes on port 80 and request for www. get sent though on port 81. The customer connects to www.example.com on port 80 but then gets from the load balancer to the server on port 81. When we add

Rewrite URL using Apache for redirecting root domain

亡梦爱人 提交于 2019-12-22 12:19:36
问题 I have this scenario where I would like to redirect my domains using the following scenario. Can you please advice if this can be achieved using RewriteRule in Apache? I would like to redirect any calls made using http://www.domainname.com/url to redirect to http://domainname.com/url. I was able to achieve the above using the following rewrite rule # BEGIN WithoutWWW RewriteEngine on RewriteCond %{HTTP_HOST} ^www\.domainname\.com$ [NC] RewriteRule ^(.*)$ http://domainname.com/$1 [R=301,L] #

htaccess - canonical URL when redirecting to subdirectory

血红的双手。 提交于 2019-12-22 12:09:12
问题 I've been playing around with this problem for quite a while but can't find the way how to achieve what I want. I want user coming to my website test.com to reach index.php located in subdirectory www immediatelly, which I am able to do. But when the URL is test.com/www I want it to be just test.com. Snippets of code: .htaccess in / RewriteRule ^(.*)$ /www/$1 [L] .htaccess in /www RewriteCond %{REQUEST_URI} ^/www.*$ RewriteRule ^/www/(.*)$ /$1 [L] gives me 500 Internal Error. UPDATE: I came

MVC public folder htaccess not working

霸气de小男生 提交于 2019-12-22 11:35:52
问题 I recently moved my index.php (the file that handles routing) and css/js/font assets to a public/ folder. I only want items in this public/ folder to be accessible for security purposes. I ran into this problem when I realized I could visit mysite.com/composer.lock and view the composer lock file with my old .htaccess and folder setup. Here is what I want If I visit mysite.com/car/create , I want it to actually point to mysite.com/public/index.php?path=car/create If I link to an asset such as