Forum Moderators: phranque
We developed a large custom joomla based website in a back directory while we built our social networking site in the root folder. Now that we are finished with the joomla based front end we moved it into root and everything is fine except the htaccess.
we have the rewrite rule on for the profiles of the social network so it will go to their custom urls they set.. BUT in the joomla I need to have some rewrites in there for the search engine friendly urls.
what we currently have in there now looks like this
RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_FILENAME}!-f
RewriteCond %{REQUEST_FILENAME}!-d
#RewriteRule ^(.*)$ url_redir.php?display_url=$1
RewriteRule ^(.*)$ view_profile.php?display_url=$1 and i need to keep that for the social networking stuff but i need to add in basically the same thing with just different rewrite rule stuff from the SEF htaccess.
Is there any way to get it to do both?
RewriteCond %{REQUEST_URI} ^(/component/option,com) [NC,OR] ##optional - see notes##RewriteCond %{REQUEST_URI} (/¦\.htm¦\.php¦\.html¦/[^.]*)$ [NC]
RewriteCond %{REQUEST_FILENAME}!-f
RewriteCond %{REQUEST_FILENAME}!-d
RewriteRule (.*) index.php
it seems like i can only have one or the other :(
RewriteCond %{REQUEST_URI}!^/component/option [NC,OR] ##optional - see notes##
RewriteCond %{REQUEST_FILENAME}!-f
RewriteCond %{REQUEST_FILENAME}!-d
#RewriteRule ^(.*)$ url_redir.php?display_url=$1
RewriteRule ^(.*)$ view_profile.php?display_url=$1
RewriteCond %{REQUEST_URI} ^(/component/option,com) [NC,OR] ##optional - see notes##
RewriteCond %{REQUEST_URI} (/¦\.htm¦\.php¦\.html¦/[^.]*)$ [NC]
RewriteCond %{REQUEST_FILENAME}!-f
RewriteCond %{REQUEST_FILENAME}!-d
RewriteRule (.*) index.php
You might have a try with something like the above. Please note it is wholly inefficient. The best advice I could give is to use some sort of "standardized" naming convention to determine if a request should be rewritten, rather than the "is it a file" (%{REQUEST_FILENAME} !-f) and "is it a directory" (%{REQUEST_FILENAME} !-d) conditions.
EG
RewriteCond %{REQUEST_URI}!^/component/option [NC,OR] ##optional - see notes##
RewriteCond %{REQUEST_URI}!^/your-actual-directory/
#RewriteRule ^(.*)$ url_redir.php?display_url=$1
RewriteRule ^(.*)$ view_profile.php?display_url=$1
Of course, matching depends on the naming convention you use for *actual* directories/files.
Justin
Make sure you change the ¦ to a solid bar when you copy/paste. (The forum software changes a "bar" to a "broken bar".)
Make sure you add back the spaces between the closed } and the !. ("Punctuation" characters are moved "one space left" when posting, so if we forget to "double space" between a closed } and a ! they will be next to each other.)
I have not tested the code, just given an example. We try to avoid "writing code" on demand, because the supply of "code writers" is much smaller the the "need code writteners", so we prefer to point in a direction.
If you are still getting errors, please check your server logs and post an *examplified* version of the error you are receiving when implementing the code and we will try to help you from there.
Justin
I'm not a programmer at all, so to be honest I have no clue what that even means. I just know that you cant click on any links on the homepage because the SEF has changed the urls and they go to file not found.
Since both the CMS and the Social Portal are housed in the root directory I'm not really sure how to proceed. The social networking on has one url type that needs to be redirected whereas all the urls for the articles, news, music etc in the CMS needs to be search engine friendly. Sadly the one social network url needs to stay as it is or 50k peoples personal url link will no longer work and we have a ton of link backs because of them.
I'm kinda stuck.
The flag delimiter error should be related to the -d and/or -f respectively.
I wish I could be of more help.
Maybe someone else can, or has some ideas which are not 'popping' into my head?
Justin
I'd recommend putting the joomla content back into its subdirectory to solve the problem. Remember that just because the joomla *files* are stored in a subdirectory, that does not mean that the URLs need to reflect or expose that subdirectory. As mod_rewrite makes clear, URL-paths and filenames are not at all the same thing, and in fact, need have nothing in common.
mod_rewrite will need some kind of uniquely-identifiable information derived from the URL-path or the filepath, to determine which RewriteRules to apply.
Jim
# If file exists in joomla directory (prepend document root and joomla path to the request-URI, then check it)
RewriteCond %{DOCUMENT_ROOT}/joomla_directory/$1 -f
# then internally rewrite the request to that directory
RewriteRule (.*) /joomla_directory/$1 [L]
#
# Else assume it's an SEF URL
RewriteRule (.*) /SEF_files/$1 [L]
Jim