I'm trying to rewrite my URL's subdomain.
http://username.domain.com will show content of http://www.domain.com/user.php?u=username but URL stay as http://username.domain.com . (I mean url masking)
(Username's can contain a-z 0-9 and hypens) Also if subdomain is www or api, don't redirect them
I'm using this for my .htaccess
RewriteEngine on
RewriteCond %{REQUEST_URI} !^/index\.php$
RewriteCond %{HTTP_HOST} !^www\.domain\.com
RewriteCond %{HTTP_HOST} ^([^.]+)\.domain\.com
RewriteRule .* /user.php?u=%1 [L]
(After @mfarver's advice) I'm trying this
RewriteEngine on
RewriteRule .* /user.php?u=%1 [L]
but this time getting 500 Internal Server error:
[Mon May 30 20:10:44 2011] [alert] [client 81.6.xx.xxx] /home/blablabla/public_html/.htaccess: AllowOverride not allowed here
(from error log)
My server's httpd.conf file's virtualhost settings
<VirtualHost 109.73.70.169:80>
<IfModule mod_userdir.c>
UserDir disabled
UserDir enabled USERNAME
</IfModule>
<IfModule concurrent_php.c>
php4_admin_value open_basedir "/home/USERNAME/:/usr/lib/php:/usr/php4/lib/php:/usr/local/lib/php:/usr/local/php4/lib/php:/tmp"
php5_admin_value open_basedir "/home/USERNAME/:/usr/lib/php:/usr/local/lib/php:/tmp"
</IfModule>
<IfModule !concurrent_php.c>
<IfModule mod_php4.c>
php_admin_value open_basedir "/home/USERNAME/:/usr/lib/php:/usr/php4/lib/php:/usr/local/lib/php:/usr/local/php4/lib/php:/tmp"
</IfModule>
<IfModule mod_php5.c>
php_admin_value open_basedir "/home/USERNAME/:/usr/lib/php:/usr/local/lib/php:/tmp"
</IfModule>
<IfModule sapi_apache2.c>
php_admin_value open_basedir "/home/USERNAME/:/usr/lib/php:/usr/php4/lib/php:/usr/local/lib/php:/usr/local/php4/lib/php:/tmp"
</IfModule>
</IfModule>
ServerName DOMAIN.net
ServerAlias *.DOMAIN.net
<Directory "/home/USERNAME/public_html">
Options FollowSymLinks
Allow from all
AllowOverride All
</Directory>
DocumentRoot /home/USERNAME/public_html
ServerAdmin webmaster@DOMAIN.net
UseCanonicalName Off
CustomLog /usr/local/apache/domlogs/DOMAIN.net combined
CustomLog /usr/local/apache/domlogs/DOMAIN.net-bytes_log "%{%s}t %I .\n%{%s}t %O ."
## User USERNAME # Needed for Cpanel::ApacheConf
<IfModule mod_suphp.c>
suPHP_UserGroup USERNAME USERNAME
</IfModule>
<IfModule !mod_disable_suexec.c>
SuexecUserGroup USERNAME USERNAME
</IfModule>
ScriptAlias /cgi-bin/ /home/USERNAME/public_html/cgi-bin/
# To customize this VirtualHost use an include file at the following location
# Include "/usr/local/apache/conf/userdata/std/2/USERNAME/DOMAIN.net/*.conf"
</VirtualHost>
Also *.DOMAIN.net added to my DNS ZONES as A record.
.htaccessfile is working. I'm not similar with .htaccess commands very well. First i will comment out 2nd 3th and 4th lines right? – Eray May 30 '11 at 18:30httpdafter editinghttpd.conf– Alvin Wong Sep 02 '12 at 03:48AllowOverride not allowed here: says what the problem is. Totally unrelated to the rewrite. That user is using a directive in .htaccess that isn't allowed (think about it, if you'd allow AllowOverride in .htacces, then it has zero use for server and vhost level and the webserver admin looses control). – Jan 22 '14 at 23:50