The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.
|
 |
|
Dev Shed Forums
> System Administration
> Apache Development
|
URL rewriting broken without trailing slash
Discuss URL rewriting broken without trailing slash in the Apache Development forum on Dev Shed. URL rewriting broken without trailing slash Apache Development forum discussing HTTP Server general topics, configuration, and modules. Apache is an open source web server that runs on multiple platforms.
|
|
 |
|
|
|
|

Dev Shed Forums Sponsor:
|
|
|

February 19th, 2013, 08:23 PM
|
|
Registered User
|
|
Join Date: Nov 2012
Posts: 20
Time spent in forums: 3 h 48 m 11 sec
Reputation Power: 0
|
|
|
URL rewriting broken -- subfolder works, root folder doesn't
I feel like this should be an easy bug to fix, but I don't see it. I am very new to Apache and rewrite rules.
I have three four on my site. Two use a multi-site wordpress install, one uses Elgg and the fourth is codeigniter.
/social/ -> elgg
/actions/ -> codeigniter
/about/ -> wordpress
/academy/ -> wordpress
My problem is in the /social/ rewrite. Everything else works. I actually removed everything else and the social rewrite gives me a problem. What I need is for
/social -> /elgg-core/
/social/ -> /elgg-core/
/social/whatever -> /elgg-core/whatever
/whatever/ -> /elgg-core/profile/whatever
Here is what I have:
Code:
### Third, check for the social module
RewriteRule ^social(.+)$ elgg-core/$1 [NC,L]
### Last, look for a user profile or 404 error
RewriteRule ^(.+)$ elgg-core/profile/$1 [NC,L]
The profile rewrite works and anything like /social/whatever works, but the /social and /social/ give me 404 errors.
Any help would be greatly appreciated
Here is the code in context, if needed
Code:
<IfModule mod_rewrite.c>
RewriteEngine On
### Where do we begin?
RewriteBase /dmgconnect/
### Where is the wordpress multisite file?
RewriteRule ^wordpress\.php$ - [L]
### add a trailing slash to /wp-admin
RewriteRule ^([_0-9a-zA-Z-]+/)?wp-admin$ $1wp-admin/ [R=301,L]
### Set our conditions
RewriteCond $1 !^(index\.php|images|robots\.txt)
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
#### URL Rewrite Rules
### First, check for wordpress sites (about, academy)
RewriteRule ^ - [L]
# Rewrite the wordpress admin stuff
RewriteRule ^(.+)/?(wp-(content|admin|includes).*) wp-core/$2 [L] #
RewriteRule ^(.+)/?(.*\.php)$ wp-core/$2 [L]
# Rewrite for the two sites (if more added, we must rewrite for them specifically
RewriteRule ^about(.+) wordpress.php [L]
RewriteRule ^academy(.+) wordpress.php [L]
### Second, is there anything for CodeIgniter specifically?
RewriteRule ^actions/(.+)$ index.php/$1 [NC,L]
### Third, check for the social module
RewriteRule ^social(.+)$ elgg-core/$1 [NC,L]
### Last, look for a user profile or 404 error
RewriteRule ^(.+)$ elgg-core/profile/$1 [NC,L]
</IfModule>
Last edited by chrismichaels84 : February 20th, 2013 at 01:24 PM.
Reason: Clarification
|

February 20th, 2013, 12:25 PM
|
 |
Still alive
|
|
Join Date: Mar 2007
Location: Washington, USA
|
|
|
.+ means one or more characters. Sounds like you want .* meaning zero or more characters.
|

February 20th, 2013, 01:16 PM
|
|
Registered User
|
|
Join Date: Nov 2012
Posts: 20
Time spent in forums: 3 h 48 m 11 sec
Reputation Power: 0
|
|
Thanks for the reply. That gets me somewhere, but I'm still getting a strange 404.
My problem is in the /social/ rewrite. Everything else works. I actually removed everything else and the social rewrite give me a problem. What I need is for
/social -> /elgg-core/
/social/ -> /elgg-core/
/social/whatever -> /elgg-core/whatever
/whatever/ -> /elgg-core/profile/whatever
Here is what I have:
Code:
### Third, check for the social module
RewriteRule ^social(.+)$ elgg-core/$1 [NC,L]
### Last, look for a user profile or 404 error
RewriteRule ^(.+)$ social/profile/$1 [NC,L]
The profile rewrite works and anything like /social/whatever works, but the /social and /social/ give me 404 errors.
Thanx
|

February 20th, 2013, 01:49 PM
|
 |
Still alive
|
|
Join Date: Mar 2007
Location: Washington, USA
|
|
Like I said, it sounds like you should be using .*
Also consider how "social/" will be rewritten to "elgg-core//". Note the second slash. That may be causing your 404. Try a structure more like
Code:
RewriteRule ^social(/.*)? elgg-core$1 [NC,L]
That is, "social" may be by itself but if not then it has to be followed by at least a slash.
|

February 20th, 2013, 02:08 PM
|
|
Registered User
|
|
Join Date: Nov 2012
Posts: 20
Time spent in forums: 3 h 48 m 11 sec
Reputation Power: 0
|
|
|
Thank you, I believe that took care of it!
|
Developer Shed Advertisers and Affiliates
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Rate This Thread |
Linear Mode
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|