I have a website running on ExpressionEngine and a custom backoffice based on Zend.
Both approaches expect a specific htaccess file placed in the root.
This is my structure.
http://localhost/... (ExpressionEngine pages, eg. http://localhost/calendar/events)
http://localhost/backoffice (Backoffice pages)
Before placing the backoffice on a subdomain, I wanted to know if it's possibile to have one htacces file and to apply a different set of htaccess rules based on the uri. So eg. everything with "backoffice" gets different rules.
I know you can do stuff like this:
Best I've found was the following Can I do an if/then/else in htaccess?
But I'm stuck with defined the variables based on the uri.
Thanks for your help.
regards
Vic
Put your rewrite rules for EE first and add a rule for the back office there:
RewriteCond %{REQUEST_URI} !/backoffice
RewriteRule ^ /index.php [L]
And now add the rules for the back office.
Related
I have some URLs that I would need to overwrite so that if someone looks at the source code they can't actually see the real URLs for the product images in Magento. Currently, the link is as
externalsub.domain.com/images/image123.jpg
I want to make it as
mydomain.com/images/image123.jpg
How can I achieve this via .htaccess? Any help is much appreciated!
Then in an htaccess file, you can use this (above whatever rules you may already have):
RewriteEngine On
RewriteRule ^images/([^/]+\.(?:jpe?g|png|gif))$ http://externalsub.domain.com/images/$1 [L,P]
You don't need the line turning on the rewrite engine if you already have that (only needs to be in your file once).
I need to modify all requests bearing the form
http://example.com/dw2/dokuwiki/doku.php/page to
http://example.com/dw2/dokuwiki/doku.php/page?do=export_xhtml
The page bit is variable - it corresponds to each paage in the wiki. I should mention that given the way dokuwiki syntax works page could contain one or more colons. e.g. glossary:archive.
The intent here is to extract the bare page content (shorn of the header, sidebar etc) of the wiki for distribution via a CDN. This does not give a complete solution since dokuwiki still leaves in a lot of unrequired verbiage in the exported markup file but gets me most of the way there. I'd much appreciate any help with this.
Place this rule as your very first rule in /dw2/dokuwiki/.htaccess:
RewriteEngine On
RewriteBase /dw2/dokuwiki/
RewriteCond %{QUERY_STRING} ^$
RewriteRule ^(doku\.php/[^/]+)/?$ $1?do=export_xhtml [L,NC,QSA,R,NE]
I want to rewrite the newsletter page of my site to url.com/newsletter/ the problem is, I have another rule overlapping this step. The rules looks like this :
RewriteRule ^([^/]*)/$ /index.php?categories=$1 [L,QSA] //Primeryrule overlapping the secondary rule
RewriteRule ^newsletter/$ /?newsletter=$1 [L]
Is there any possibility to apply special case rules or something like that (I don't want to use any workaround like .html or .php extension or stuff like this, just the url as above).
Apache reads these rules from the top down. So put your new rule first and then the existing rule and give it a try.
Just found the solution, that I need to keep the newsletter rule on top of the other rule to make it apply first.
I have been researching redirects for a few days now and am still struggling, so I decided to post my first question here. For some reason, it is just not clicking for me.
I have redesigned and developed a client's WordPress site and need to update it's structure.
The site's current structure is:
www.domain.com/blog/postname/2011/12/26/
The new structure should be:
www.domain.com/blog/postname
I really thought this was going to be easy since all I am looking to do is drop the date, but have not been able to grasp the whole wildcard aspect and how to end what I am trying to match. Any help would be greatly appreciated. A simple answer is great, but an explanation would be even better.
I am assuming you already know how to change your WordPress permalink structure to drop the date.
To 301 redirect all of the old URLs to the new ones, add the following rules to your .htaccess file in the root of your websites domain, ahead of any existing rules that are there.
#if these 2 lines already exist, skip them and add the rest
RewriteEngine on
RewriteBase /
# if there is a request of the form /blog/post-name/yyyy/mm/dd/
RewriteCond %{REQUEST_URI} ^(/blog/[^/]+/)[0-9]{4}/[0-9]{2}/[0-9]{2}/$ [NC]
#redirect the request to the URL without the date
RewriteRule . %1 [L,R=301]
If you want to learn more about .htaccess/rewriting you can take a look at the following urls: Indepth htaccess, Brief Introduction to Rewriting, Apache Mod_rewrite.
Let me know if this works for you and/or you have any issues.
I have a slight problem with .htaccess redirect.
I have a dynamic site with 2 levels of variables - content="type -(alpha)" and ID="number" but this is very not seo friendly what I really would like to create is a rewrite rule that generates a "friendly" url for serach engines & users alike. Very much like WordPress does.
Each ID is already unique (obviously) and on creation is creating a unique "permalink" field so for example ID=1 has a "permalink field" as "2009/10/27/page title" and ID=100 would be "2010/10/27 page title".
I would like folder/wall.php?content=type&ID=number to redirect to folder/permalink.php/html/htm (don't mind a non dynamic extension)
Any clues? - this is not right (I know) but it also "breaks" my css file
RewriteEngine On
RewriteRule wall/content/(.*)/ID/(.*)/ wall.php?content=$1&ID=$2
RewriteRule wall/content/(.*)/ID/(.*) wall.php?content=$1&ID=$2
You need to make sure you have a URL convention that won't conflict with other files on the server. For example, if your page is displaying "Products" and you don't have an actual folder in the root of your server called /products/, you could do this
RewriteEngine On
RewriteRule ^products/([^/\.]+)/([^/\.]+)/?$ wall.php?content=$1&id=$2 [L,NC,QSA]
Replace "products" in this example with whatever name is most appropriate for what your wall.php page does.
This would equate to the following URL
www.yoursite.com/products/title/29/
Which would rewrite to
www.yoursite.com/wall.php?content=title&id=29