?
Solved

apache .htaccess

Posted on 2010-01-09
6
Medium Priority
?
363 Views
Last Modified: 2012-05-08
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
Comment
Question by:yarekGmail
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 
LVL 6

Expert Comment

by:V4nP3rs13
ID: 26273177
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
 

Author Comment

by:yarekGmail
ID: 26273282
Hisblog Is variable !
0
 
LVL 6

Expert Comment

by:V4nP3rs13
ID: 26273327
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
Independent Software Vendors: 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!

 

Author Comment

by:yarekGmail
ID: 26273543
Hisblog Is variable !
0
 
LVL 26

Expert Comment

by:arober11
ID: 26273751
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
 
LVL 5

Accepted Solution

by:
bplant earned 2000 total points
ID: 26329034
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

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!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you are a web developer, you would be aware of the <iframe> tag in HTML. The <iframe> stands for inline frame and is used to embed another document within the current HTML document. The embedded document could be even another website.
Lease-to-own eliminates the expenditure of hardware replacement and allows you to pay off the server over time. Usually, this is much cheaper than leasing servers. Think of lease-to-own as credit without interest.
The purpose of this video is to demonstrate how to set up an RSS Feed on a WordPress Website. This will be demonstrated using a Windows 8 PC. Feedburner will be used for this demonstration. Go to your WordPress login page. This will look like the…
The is a quite short video tutorial. In this video, I'm going to show you how to create self-host WordPress blog with free hosting service.
Suggested Courses

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question