Forum Moderators: phranque
Is there a simple way to do this in a .htaccess file:
IF REQUEST_URL = WWW.EXAMPLE.COM THEN
{
RewriteEngine On
Options +Followsymlinks
RewriteBase /
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.* - [L,QSA]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^.*/images/(.*)$ /community/images/$1 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^.*/uploads_user/(.*)$ /community/uploads_user/$1 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^/]+)/?$ /community/profile.php?user=$1 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^/]+)/albums/([0-9]+)/([0-9]+)/?$ /community/album_file.php?user=$1&album_id=$2&media_id=$3 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^/]+)/albums/([0-9]+)/?$ /community/album.php?user=$1&album_id=$2 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^/]+)/albums/([0-9]+)/([^/]+)?$ /community/album.php?user=$1&album_id=$2$3 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^/]+)/albums/?$ /community/albums.php?user=$1 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^/]+)/classifieds/([0-9]+)/?$ /community/classified.php?user=$1&classified_id=$2 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^/]+)/classifieds/([0-9]+)/([^/]+)?$ /community/classified.php?user=$1&classified_id=$2$3 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^/]+)/classifieds/?$ /community/classifieds.php?user=$1 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^/]+)/blog/([0-9]+)/?$ /community/blog_entry.php?user=$1&blogentry_id=$2 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^/]+)/blog/([^/]+)?$ /community/blog.php?user=$1$2 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^/]+)/blog/?$ /community/blog.php?user=$1 [L]
}
ELSEIF REQUEST_URL = WWW.EXAMPLE.ES THEN
{
RewriteEngine On
Options +Followsymlinks
RewriteBase /
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.* - [L,QSA]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^.*/images/(.*)$ /comunidad/images/$1 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^.*/uploads_user/(.*)$ /comunidad/uploads_user/$1 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^/]+)/?$ /comunidad/profile.php?user=$1 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^/]+)/albums/([0-9]+)/([0-9]+)/?$ /comunidad/album_file.php?user=$1&album_id=$2&media_id=$3 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^/]+)/albums/([0-9]+)/?$ /comunidad/album.php?user=$1&album_id=$2 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^/]+)/albums/([0-9]+)/([^/]+)?$ /comunidad/album.php?user=$1&album_id=$2$3 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^/]+)/albums/?$ /comunidad/albums.php?user=$1 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^/]+)/classifieds/([0-9]+)/?$ /comunidad/classified.php?user=$1&classified_id=$2 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^/]+)/classifieds/([0-9]+)/([^/]+)?$ /comunidad/classified.php?user=$1&classified_id=$2$3 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^/]+)/classifieds/?$ /comunidad/classifieds.php?user=$1 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^/]+)/blog/([0-9]+)/?$ /comunidad/blog_entry.php?user=$1&blogentry_id=$2 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^/]+)/blog/([^/]+)?$ /comunidad/blog.php?user=$1$2 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^/]+)/blog/?$ /comunidad/blog.php?user=$1 [L]
}
Hope that makes sense, (if it helps it's only the directory name that is different, the .php files remain the same).
Help! Thanks in advance.
RewriteEngine On
Options +FollowSymLinks
#
# Skip all following rules if the requested URL resolves to existing directory or file
RewriteCond %{REQUEST_FILENAME} -d [OR]
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule .* - [L]
#
# Set requested-hostname/language-based "community" directory name to "community" (default value)
RewriteRule . - [E=ComDir:community]
#
# If Spanish tld requested, set "community" directory name to "comunidad"
RewriteCond %{HTTP_HOST} ^www\.example\.es
RewriteRule . - [E=ComDir:comunidad]
#
RewriteRule /images/(.*)$ /%{ENV:ComDir}/images/$1 [L]
RewriteRule /uploads_user/(.*)$ /%{ENV:ComDir}/uploads_user/$1 [L]
RewriteRule ^([^/]+)/?$ /%{ENV:ComDir}/profile.php?user=$1 [L]
RewriteRule ^([^/]+)/albums/([0-9]+)/([0-9]+)/?$ /%{ENV:ComDir}/album_file.php?user=$1&album_id=$2&media_id=$3 [L]
RewriteRule ^([^/]+)/albums/([0-9]+)/?$ /%{ENV:ComDir}/album.php?user=$1&album_id=$2 [L]
RewriteRule ^([^/]+)/albums/([0-9]+)/([^/]+)?$ /%{ENV:ComDir}/album.php?user=$1&album_id=$2$3 [L]
RewriteRule ^([^/]+)/albums/?$ /%{ENV:ComDir}/albums.php?user=$1 [L]
RewriteRule ^([^/]+)/classifieds/([0-9]+)/?$ /%{ENV:ComDir}/classified.php?user=$1&classified_id=$2 [L]
RewriteRule ^([^/]+)/classifieds/([0-9]+)/([^/]+)?$ /%{ENV:ComDir}/classified.php?user=$1&classified_id=$2$3 [L]
RewriteRule ^([^/]+)/classifieds/?$ /%{ENV:ComDir}/classifieds.php?user=$1 [L]
RewriteRule ^([^/]+)/blog/([0-9]+)/?$ /%{ENV:ComDir}/blog_entry.php?user=$1&blogentry_id=$2 [L]
RewriteRule ^([^/]+)/blog/([^/]+)?$ /%{ENV:ComDir}/blog.php?user=$1$2 [L]
RewriteRule ^([^/]+)/blog/?$ /%{ENV:ComDir}/blog.php?user=$1 [L]
Jim
# Redirect to canonicalize domain names
#RewriteCond %{HTTP_HOST} !^www\.example\.es$
RewriteRule (.*) http://www.example.es/$1 [R=301,L]
#
RewriteCond %{HTTP_HOST} !\.es\.?(:[0-9]+)$
RewriteCond %{HTTP_HOST} !^www\.example\.com$
RewriteRule (.*) http://www.example.com/$1 [R=301,L]
Jim
[edited by: jdMorgan at 7:05 pm (utc) on Sep. 1, 2008]
# Redirect to canonicalize domain names
#
RewriteCond %{HTTP_HOST} \.es\.?(:[0-9]+)$
RewriteCond %{HTTP_HOST} !^www\.example\.es$
RewriteRule (.*) http://www.example.es/$1 [R=301,L]
#
RewriteCond %{HTTP_HOST} !\.es\.?(:[0-9]+)$
RewriteCond %{HTTP_HOST} !^www\.example\.com$
RewriteRule (.*) http://www.example.com/$1 [R=301,L]