Forum Moderators: phranque
RewriteEngine on
RewriteCond $1!^(favicon\.ico¦index\.php).*
RewriteRule ^(.*) index.php/jamie/$1
This portion of the .htaccess files is working perfectly. However there is one condition where the script I am using with these settings will throw something into the url that doesn't work. To be specific it will put the text
jamie
into the url which the script does not understand since I have the RewriteRule above that is putting
index.php/jamie/
into the url so the server is actually trying to visit
index.php/jamie/jamie/
which of course is goofy. I'm wondering if it would be possible to add some conditions and rules that would look to see if [mydomain...] is there and if it is to redirect to [mydomain...]
Anyone willing to help out a newbie? I will be incredibly grateful. I don't need anything passed to the script I just need it redirected so that the user doesn't know that the url was ever wrong in the first place.
Thanks a lot to anyone willing to take the time to help me out here. I greatly appreciate it.
Jamie
So this does not work:
RewriteEngine on
RewriteCond $1!^(favicon\.ico¦index\.php).*
RewriteRule ^(.*) index.php/jamie/$1
RedirectMatch 301 /jamie/(.*) /$1
Neither does this:
RewriteEngine on
RedirectMatch 301 /jamie/(.*) /$1
RewriteCond $1!^(favicon\.ico¦index\.php).*
RewriteRule ^(.*) index.php/jamie/$1
I'm suspecting I need some sort of rewrite condition and then skipping of the rule if the condition doesn't occur.
Any ideas?
Jamie
I have a Rewrite Condition now that will check if the url already has /jamie/ in it. If it is in it then it skips the next rule. This looks like this:
RewriteCond!^/jamie/$ [S=1]
Now I need a Rule that does what the Rewrite Match you gave me did. Maybe I will be able to figure this one out on my own but I could certainly use some help.
Jamie
Here is what I have now but it must not be formated right or something because it doesn't seem to be be getting rid of /jamie/
RewriteEngine on
RewriteCond!^/jamie/$ [S=1]
RewriteRule ^/jamie/(.*)$ [mydomain.com...] [R=301]
RewriteCond $1!^(favicon\.ico¦index\.php).*
RewriteRule ^(.*) index.php/jamie/$1 [L]
The third line is the one in question.
Anyone?
This is your original rule:
RewriteEngine on
RewriteCond $1!^(favicon\.ico¦index\.php).*
RewriteRule ^(.*) index.php/jamie/$1
The only way that you are getting /jamie/jamie/ is if this ruleset is in the root and the directory jamie/ is being stored in the variable.
You have two options:
1. move the .htaccess file to the jamie/ directory, then the directory will not be stored by the varible, because it is the directory you are in and not used in comparrison.
2. change your rule to the specific directory of jamie/ and then use the catch all after that to store the pages. EG
RewriteRule ^jamie/(.*)$ /index.php/jamie/$1 [L]
Hope this helps.
Justin
Added: added a hard ending ($) to the left side of the rule, and a / to the right side... required in the .htaccess file, because the request is being sent back through the server. Ended the Rule with [L] last flag... should always be used unless you know you don't need it.
I can't test what you just gave me until this evening but I wanted to mention one thing and see if this will cause a problem. The /jamie/ is not actually a directory it is actually a query string of sorts that the script uses to know which template_group i want the templates from the script to be loaded from. So there is not physical directory by that name. It is all in the mind of the script. That means I can't move the .htaccess file anywhere but root since there are no directories in root. It contains only the index.php a path.php file that the index.php refers to, a favicon.ico and the .htaccess file. There is nothing else physically in the directory.
How would this change what I need to do?
Jamie
RewriteCond $1!^(favicon\.ico¦index\.php)
RewriteRule ^(.*)$ /index.php/jamie/$1 [L]
Rule 1: Send jamie/jamie (/ made optional by the use of ?) to jamie/ with a 301, external (visible) redirect.
Rule 2: store all file path info in a variable and make sure it is not a favicon.ico or index.php file.
Removed the .* from the condition. No point in determining a match if you do not need to store it as a variable or compare it to anything, so by leaving the line end ($) off, you can use the implicit 'and anything else'
Think this should get you close...
Sorry, I did not know exactly what you were asking the first time.
Justin