Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 366
  • Last Modified:

apache .htaccess

Hello experts
I have a website based on wordpressMU.
when someone creates his blogs, the url is
www.mysite.com/blog/HISBLOG

which is a very long URL
Is there a a way to make it short ?
like:
www.mysite.com/HISBLOG
or
HISBLOG.mysite.com

I guess some .htaccess ?
 
0
yarekGmail
Asked:
yarekGmail
1 Solution
 
V4nP3rs13Commented:
yes... you can do it with htaccess. First, mod_rewrite must be enabled/installed (you can check it with phpinfo() function)... then write tihs code in htaccess

RewriteEngine on
RewriteRule HISBLOG blog/HISBLOG

I hope this helps
0
 
yarekGmailAuthor Commented:
Hisblog Is variable !
0
 
V4nP3rs13Commented:
whatt?? I don't understand what you want to do... i gave you the code for changing blog/HISBLOG into HISBLOG... what you want? You must precisely explain us what do you want to change with htaccess
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
yarekGmailAuthor Commented:
Hisblog Is variable !
0
 
arober11Commented:
Hi

The following may get you most of the way there:

RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f     # Not a physical file
RewriteCond %{REQUEST_FILENAME} !-d    # Not a physical directory
RewriteCond  %{REQUEST_URI}   ^/blog/    # Not for an alias, guessing blog is an alias
RewriteRule ^(.*)  /blog/$1    [L]

If you want the URL, in the browser bar, to change the replace the [L] with a [R=301,L]
0
 
bplantCommented:
Hi yarekGmail,

If you want to do foo.mysite.com, then you'll first need to add a wildcard DNS record for *.mysite.com so that the requests actually make it to your server. Then you'll need to add the following to your vhost file and reload apache.

ServerAlias "*.mysite.com"

The last task is your .htaccess. You'll need something like this. Note I have _not_ tested these rules.

RewriteEngine On
RewriteCond %{HTTP_HOST} !^mysite\.com$ [NC]
RewriteCond %{HTTP_HOST} !^www\.mysite\.com$ [NC]
RewriteRule ^(.*) %{HTTP_HOST}$1 [C]
RewriteRule ^([^.]+)\.mysite\.com(.*) /blog/$1$2

I used examples from the following page to build the above rules.
http://httpd.apache.org/docs/2.0/misc/rewriteguide.html

Hope this helps,

Brad
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now