Rewrite question
8 posts
• Page 1 of 1
Rewrite question
Hi all,
New to URL rewritting so forgive if this has been addressed elsewhere...
I'm trying to rewrite a url which is a number of folders deep, i.e. http://www.site.com/resources/directory ... /john-doe/ and make it end up being http://www.site.com/john-doe..
I was hoping to make one rule for all the peoples pages so that I don't need to make a rule for each.
I tried something like this;
rewriterule ^/resources/directory/people/(.*)/?$ /$1/ [NC]
But no go.
I'm sure I'm misunderstanding or doing something wrong, so any help would be great!
Thanks in advance!
Brance
New to URL rewritting so forgive if this has been addressed elsewhere...
I'm trying to rewrite a url which is a number of folders deep, i.e. http://www.site.com/resources/directory ... /john-doe/ and make it end up being http://www.site.com/john-doe..
I was hoping to make one rule for all the peoples pages so that I don't need to make a rule for each.
I tried something like this;
rewriterule ^/resources/directory/people/(.*)/?$ /$1/ [NC]
But no go.
I'm sure I'm misunderstanding or doing something wrong, so any help would be great!
Thanks in advance!
Brance
- HeliconAndrew
- Posts: 1264
- Joined: 07 Mar 2012, 10:16
Re: Rewrite question
Hello,
Try using:
Regards
Try using:
- Code: Select all
RewriteEngine on
RewriteBase /
RerwriteRule ^resources/directory/people/([^/]+)/?$ /$1/ [NC,R=301,L]
Regards
Re: Rewrite question
Unfortunately that doesn't work either, as I receive a 404 when typing in the URL www.site.com/personsname/ Of course it could be that the prior rules to remove the "index.php" and force all requests to go through the ExpressionEngine system first (someone else wrote/created that part) makes it fail... However I guess what I'm not getting is how if the rule needs to have the first pattern "/resources/directory/people/personsname" to match on in order to rewrite to www.site.com/personsname/ it would ever work simply typing www.site.com/personsname in the address bar...
Am I being dense???
Am I being dense???
- HeliconAndrew
- Posts: 1264
- Joined: 07 Mar 2012, 10:16
Re: Rewrite question
Well,
At the beginning I didn't know what you needed, now I'm getting an idea. You needs a second rule to map the content for a new pretty URL:
So in this case, it'd check all requests that are only /XYZ/, not longer, then it'll check if such file or directory is real and rewrite it.
Regards
At the beginning I didn't know what you needed, now I'm getting an idea. You needs a second rule to map the content for a new pretty URL:
- Code: Select all
RewriteEngine on
RewriteBase /
RerwriteRule ^resources/directory/people/([^/]+)/?$ /$1/ [NC,R=301,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RerwriteRule ^([^/]+)/?$ /resources/directory/people/$1/ [NC,L]
So in this case, it'd check all requests that are only /XYZ/, not longer, then it'll check if such file or directory is real and rewrite it.
Regards
Re: Rewrite question
Thank you Andrew! And as I'm understanding more I'm not sure what I want to accomplish is going to even work given that there is already a RequestCond and rewriteRule sending the request via the index.php file of the CMS system (ExpressionEngine). There is no directory per se, at least I can't find one in the wwwroot relating to the actual URL that is presented. It must be creating that directory structure via index.php within EE...
- HeliconAndrew
- Posts: 1264
- Joined: 07 Mar 2012, 10:16
Re: Rewrite question
Could you share those rules you have?
Re: Rewrite question
Sure!
# Removes index.php from ExpressionEngine URLs
RewriteCond %{THE_REQUEST} ^GET.*index\.php [NC]
RewriteCond %{REQUEST_URI} !/cms_system/.* [NC]
RewriteRule (.*?)index\.php/*(.*) /$1$2 [R=301,NE,L]
# Directs all EE web requests through the site index file
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php/$1 [L]
Of course these are at the root htaccess file. I would attempt to put the rewrite rules in the folder for the resources/directory/people but those folders don't exist in the webroot, I believe they are dynamically created via the EE system.
# Removes index.php from ExpressionEngine URLs
RewriteCond %{THE_REQUEST} ^GET.*index\.php [NC]
RewriteCond %{REQUEST_URI} !/cms_system/.* [NC]
RewriteRule (.*?)index\.php/*(.*) /$1$2 [R=301,NE,L]
# Directs all EE web requests through the site index file
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php/$1 [L]
Of course these are at the root htaccess file. I would attempt to put the rewrite rules in the folder for the resources/directory/people but those folders don't exist in the webroot, I believe they are dynamically created via the EE system.
- HeliconAndrew
- Posts: 1264
- Joined: 07 Mar 2012, 10:16
Re: Rewrite question
Well,
this is quite different from what I expected. Usually we fix these differently by collaborating with a CMS. For example, take a look at WP - http://www.helicontech.com/articles/tun ... mpression/. However, i'm not familiar with EE. If you could investigate and see what it can do in terms of customized URL structure.
Regards
this is quite different from what I expected. Usually we fix these differently by collaborating with a CMS. For example, take a look at WP - http://www.helicontech.com/articles/tun ... mpression/. However, i'm not familiar with EE. If you could investigate and see what it can do in terms of customized URL structure.
Regards
8 posts
• Page 1 of 1
Who is online
Users browsing this forum: No registered users and 4 guests