I want to redirect
http://subdom.domain.com/guidelines/article1
http://subdom.domain.com/guidelines/article2
http://subdom.domain.com/guidelines/article3
to
http://subdom.domain.com/notsoguideline/noarticlepage/blahblah
so I wrote the following rule in .htaccess of my wordpress site but it doesn't seem to work
RewriteRule ^guidelines/([^/]+)/ /notsoguideline/noarticlepage/blahblah/
Check that your hosting supports and allows the use of .htaccess files.
Ensure that you have RewriteEngine On in your .htaccess (before your custom rules)
If you create a nonsense .htaccess file what happens? If nothing then your .htaccess file is not in use.
Related
I'm trying to get my .htaccess file to work with PHPDesktop, but .htaccess doesn't seem to work. I saw that it's possible to hide specific files in the settings.json file, but it seems pretty limited. Is there a way to use my .htaccess file instead of using the settings.json file? Here's what I use for my .htaccess file:
RewriteEngine On
RewriteRule ^public/(.+) public/$1 [END] # allow direct access on public folder
RewriteRule ^ index.php [END] # anything else will be directed to index.php
No, you can't use .htaccess with PHP Desktop. PHP Desktop embeds a Mongoose web server which doesn't support such configuration file.
The rewrite rules from your .htaccess can be handled by setting web_server > 404_handler in settings.json file to /index.php.
I have a content management system plugin installed that provides a sitemap for Google under http://www.domain.com/index.php?eID=dd_googlesitemap how can I add a rewrite rule to my .htaccess that will make this sitemap available under http://www.domain.com/sitemap.xml instead?
You can add this code to your htaccess file (which has to be in root folder)
RewriteEngine On
RewriteRule ^sitemap\.xml$ /index.php?eID=dd_googlesitemap [L]
Make sure mod_rewrite is enabled
I had to adjust some paths on my site and I need to use .htaccess to redirect the items on the chance a user accesses the old url.
For example my old urls (relative) could be:
/old-path/page1.php
/old-path/page2.php
/old-path/page3.php
etc...
I had to change the path (for this example) to new-path and I need to adjust the .htaccess so anyone that comes to any page with .../old-path/... will be redirected to
.../new-path/...
Also, would this satisfy the 301 or would I need to list out each page?
You can use either mod+alias:
Redirect 301 /old-path /new-path
or using mod_rewrite:
RewriteEngine On
RewriteRule ^/?old-path/(.*)$ /new-path/$1 [L,R=301]
These could be in the htaccess file in your document root or in the server/vhost config. If you already have rewrite rules somewhere, you may just want to stick with mod_rewrite because redirecting with mod_alias while using mod_rewrite can sometimes give conflicting results.
I have a /public folder in which there is an .htaccess file with a lot of rewrite rules.
We are making a new folder at /public/news, the rules of the first .htaccess file apply in this folder too and that's undesirable.
I don't have access to server's virtual host definition so my only other option is to put exceptions in every rewrite rule in the /public/.htaccess which is not preferable.
I was wondering if I could put a new .htaccess file in /public/news so that it will disable all the effects of the first .htaccess
Add this to your /public/.htaccess at the top (before other rules, after RewriteEngine On):
RewriteRule ^news(.*)$ - [L]
It will not rewrite anywhere because of the -, and the [L] will cause the current .htaccess to stop processing more rules (the last flag). Then the /public/news/.htaccess can take effect.
Apache Mod_Rewrite Documentation
The suggested answer above works, but I was hoping to find a way so that I don't have to modify /public/.htaccess
The solution was to put
RewriteEngine off
In /public/news/.htaccess
I suck at htaccess and trying to achieve the following set of redirections. Any help would be greatly appreciated. I can't find anything on askapache and I don't understand general htaccess rules formating.
domain1.com/x -> sub.domain2.com (x being any page and file under this domain, but not the bare domain itself)
domain1.com -> domain2.com (when they type the bare domaine, redirect to the new one)
.htaccess can be used to modify behavior of any directory. Unless you set rule for /x to one directory, you can't use .htaccess. In this case it should be easier to set up redirection in Apache configuration file. Try something like this in Apache configuration file:
RewriteEngine on
RewriteRule ^/$ http://domain2.com/ [R,L]
RewriteRule ^/.+ http://sub.domain2.com/ [R,L]