I have a site hosted in a Windows Server that contains a WP install and a bunch of custom ASP pages. I have to move the whole site to a new Linux host and the ASP pages to a subdomain in a Windows Server.
I need a .htaccess script to redirect the *.asp files to a subdomain, for example, http://www.domain.com/pagex.asp?id=12345 to http://windows.domain.com/pagex.asp?id=12345
Thanks in advance
RewriteEngine On
RewriteRule ^/?(.+\.asp)$ http://windows.domain.com/$1 [L,R=301]
You can test your rules here:
htaccess tester
I tested the above rule with your example url (http://www.domain.com/pagex.asp?id=12345), and it returned your example result (http://windows.domain.com/pagex.asp?id=12345).
Related
I have a website on apache web server, and I would like one of subfolders to transparently redirect to azure web app.
mydomain.org -> regular apache page
mydomain.org/something -> regular apache page
mydomain.org/azure -> redirect to azure
However, I would need the url to stay on mydomain.org, so I would like - for example mydomain.com/azure/x/y to actually show result of azuredomain.org/x/y
I believe I can do it using .htaccess with rule: RewriteRule ^(.*)$ azuredomain.org/$1 [P]
However, this results in azure 404 error with suggestion that maybe "Custom domain has not been configured inside Azure", which is in fact correct.
Is it possible to configure 'mydomain.org ' as custom domain in azure, but only for one subfolder (mydomain.org /azure/) while allowing all other urls to map to apache server?
I managed to make it work:
Create subdomain 'azure' pointing to folder 'azure'
Add .htaccess to 'azure' folder with rule RewriteRule ^(.*)$ azuredomain.org/$1 [P]
Add records to domain:
TXT / asuid.azure / [verificationID]
CNAME / azure / azuredomain.org
In Web App settings add custom domain with subdomain: azure.mydomain.org
I am Using XAMPP Server.
I have a folder or project named test in my htdocs.
I want to redirect user to redirect to newfile.htm when user access oldfile.htm direcly using htaccess.
I wrote below code in mine htaccess file but its not working
RewriteEngine on
Redirect 301 /oldfile.htm /newfile.htm
Kindly Guide me.
Redirect directive is part of apache alias module. You don't need to write RewriteEngine on to use Redirect. The reason why your Redirect failed is because you are a relative test path, you need to specify a full/absolute path in Redirect.
Redirect 301 /test/oldfile.html /test/newfile.html
should work. If the problem presists, Try clearing your browser cache and make sure you dont have other conflicting redirects in htaccess.
I'm using Liferay 6.2 EE that runs on tomcat but it's fronted by an Apache server. I want to redirect users so that whenever they hit the old liferay URL, it redirects them to the new liferay URL. I changed the URL in liferay, so it is now the new URL. However, whenever I try to go to the old URL, I get a page request error. It never redirects me to the new URL. In /san/apache/conf/ I put my redirect code inside of httpd.conf. This my code:
RewriteEngine On
RewriteRule ^group/old/(.*) /group/new/$1 [L]
After I applied these changes, I restarted the Apache server and it still doesn't work. I've tried a bunch of other combinations as well. Does anyone know what I'm doing wrong? Is there some place else I have to make this change?
Ah, since your rewrite rule is lying in the server config file (instead of htaccess file), the mod-rewrite receives URLs with the leading slashes (/). So, the rule should be:
RewriteEngine On
RewriteRule ^/group/old/(.*) /group/new/$1 [L]
I read at least a dozen of posts about it, and found something like to setup in my site's root folder (which is www/pg-dev). htaccess file:
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^weiadesigner/pg-dev
RewriteRule ^subdir/(.*)$ http://weiadesigner/pg-dev/$1 [L,R=301]
it suppose to (I think), redirect from any attempt to access weiadesigner/pg-dev to http://weiadesigner/pg-dev/$1. However, still nothing happen, I still receive the 404 Not Found issue.
I access the WAMP server through my computer name which is weiadesigner with chrome. /pg-dev is the folder where my site is. I try to tell the Apache to redirect all subdomain access (meaning, if someone access weiadesigner/pg-dev/events in a url bar in a browser) , for example weiadesigner/pg-dev/events, will respond with AngularJS router instead of the 404 Not Found from the Apache server, because I am using the HTML base tag that is setup in the index.php in its with
<base href="/pg-dev/">
<base target="_blank" href="http://weiadesigner/pg-dev/">
I am having a big hard time to find any valid solution on this.
OK, I'm looking to use mod rewrite to write seo friendly urls for my site. It works fine on my xampp local testing server. However, I'm having problems when trying to put it live, it doesn't seem to work at all.
Here's what I've written in my htaccess file:
RewriteEngine On
RewriteRule ^category/([a-zA-Z0-9]+)$ category.php?location=$1
So the idea is to change mysite.com/category.php?location=londonto mysite.com/category/london.
Initially I though it may be an issue with the ability to mod rewrite being switched on on GoDaddy's end, so I contacted GoDaddy to see if it that was the case and their response was that: "Mod_rewrite is an Apache Web server module installed on all of our Linux servers by default; it does not have to be installed or enabled. Our Linux hosting accounts support most mod_rewrite functions. Because enabling mod_rewrite is handled at a global level, you do not need to enable it in your httpd.conf file. You only need to add the desired code to the body of your .htaccess file."
And they bascially implied that the error is not with them and with my code. I'm not very experienced with mod rewrites and it seemed to work fine when I wrote it like this on other servers. Is there something special you have to write with godaddy? Am I missing something? Thanks!
Is that all in your htaccess file? What error do you get when visiting a desired URL, is it a 500 Internal Server error?
What I usualy add by default is an If-statement:
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteBase /
RewriteRule ^category/([a-zA-Z0-9_-]+)$ category.php?location=$1 [L]
</IfModule>
By the way, note the _- at the end of the charset in the rule, for instance New York has a SEF version which is new-york, category/new-york would fail in your RewriteRule.