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
Related
I have a single domain, multi store setup on magento 2.3
For example
example.com/jp/
example.com/uk/
however the sitemaps get generated to their store folders within a sitemaps folder in the root dir, such
example.com/sitemaps/jp/sitemap.xml
My google webmaster domains are setup as such
example.com/jp/
So when I need to submit a sitemap it needs to be example.com/jp/sitemap.xml
I've used
#Sitemap: Japan http://www.example.com/sitemaps/jp/sitemap.xml
RewriteCond %{HTTP_HOST} ^.*example\.com$
RewriteRule ^sitemap.xml$ sitemaps/jp/sitemap.xml [NC,L,R=301]
When I access example.com/jp/sitemap.xml its a 404
I'd like example.com/jp/sitemap.xml to redirect to example.com/sitemaps/jp/sitemap.xml
Is there a way of doing this through .htaccess?
You can use this rule as topmost rule in site root .htaccess:
RewriteEngine On
RewriteRule ^[a-z]{2}/sitemap\.xml$ /sitemaps/$0 [L,NC,R=301]
Make sure there is no other .htaccess and this rule is top most rule.
Previously my site was in wordpress, now converted into html.
I have 500+ pdfs that needs to redirect from
mysite.com/wp-content/themes/my-theme/pdfs folder to mysite.com/pdf/
Do you have server-level access to the site? If so I would create a symbolic link in the public root directory of your website to wp-content/themes/my-theme/pdfs and call it pdf.
If all you can do is .htaccess, then you can create a file like this:
Options +FollowSymLinks
RewriteEngine On
RewriteRule ^pdf/(.*)$ /wp-content/themes/my-theme/pdfs /$1 [R=301,NC,L]
You might check out a great tutorial on rewrite rules.
I tried like this it works for me.
RewriteRule ^wp-content/themes/my-theme/pdfs/(.*)$ /pdf/$1 [R=301,NC,L]
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.
I have this url:
http://mysite.com/home.php?name=username
I want to be able to access that by going to:
http://mysite.com/home/username
Is there a way to do that?
You can do this using the mod_rewrite extention that comes with Apache.
Create a new .htaccess file in your web root directory, and populate it with the following text.
RewriteEngine On
RewriteRule ^home/([^/]*)$ home.php?name=$1 [L]
My site (grosvenorauctions.com) uses a modified Wordpress install to create a custom look - the blog part is driven by WP but other parts are outside WP. Consequently the index page for my site is not in the root folder but actually within the Wordpress folder. I am using htaccess (RedirectMatch ^/$ http://www.grosvenorauctions.com/wordpress/) to point to the index page in Wordpress but additionally I would like to hide the /wordpress/ part of the url. Is this possible? To be clear the htaccess file I have modified is in the root, not WP's own htaccess file.
Thanks
RewriteEngine On
RewriteBase /
RewriteRule ^/$ /wordpress/ [L]