apache url redirection

Hi All,

I'm using apache and want to redirect the below url

http://test1.test.com/blog/sms  to http://test1.test.com/blog/?page_id=44

So when someone hits http://test1.test.com/blog/sms he should be redirected to  http://test1.test.com/blog/?page_id=44

I don't have any page called sms. (http://test1.test.com/blog/sms), but i want when some one hits, it should go to desired url.


Please help me to solve this...
sukhvinderkumarAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

donciakasCommented:
So you need to use Friendly URL's or in another words "smart urls" which are useful for SEO and of course it's easier to write them down
Please see the links below
http://www.petefreitag.com/item/503.cfm
http://articles.sitepoint.com/article/search-engine-friendly-urls/2
0
Brad HoweDevOps ManagerCommented:
Hi,

You will need Mod_rewrite enabled to have this work. It is usually installed by default so i would jsut give this a try.

If it doesn't work let me know and we can work out the mod_rewrite installation.


Add this to your Virtual host configuration.

httpd.conf
  RewriteEngine On
  RewriteLog /a/folder/youcanwriteto/rewrite.log
  RewriteLogLevel 9
  RewriteMap escape int:escape

  RewriteEngine On
  RewriteRule ^blog/sms$  /blog/?page_id=44 [R-301,L]


Or you can use a .htaccess rule file in the directory.

  RewriteEngine On
  RewriteRule ^blog/sms$  /blog/?page_id=44 [R-301,L]


Download this file and it will help you out in the future.
http://www.addedbytes.com/cheat-sheets/mod_rewrite-cheat-sheet/

Cheers,
Hades666

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
sukhvinderkumarAuthor Commented:
Hi Hades666,

Thanks for the reply.
I tried but , it's not working .. and in the error log file getting the below error.

[Tue Apr 27 16:46:29 2010] [error] [client xx.xx.xx.xx] File does not exist: /var/www/html/blog/sms

And in the browser it's giving me : The requested URL /blog/sms was not found on this server.
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

Brad HoweDevOps ManagerCommented:
Are you doing this through httpd or .htaccess?

If .htacess where did you place this file?

Have you turned on RewriteLogging?  If not can you please do so to provide the matching case to see what is being processed.

Thank you,
Hades666
0
pawwaCommented:
If this is just one thing that you want, you can simply use Apache's mod_alias (installed by default), and Redirect directive. Put this in your httpd.conf:

Redirect 301 /blog/sms http://test1.test.com/blog/?page_id=44
0
pawwaCommented:
...and of course, restart Apache.

;-)
0
Brad HoweDevOps ManagerCommented:
Yes, that will work too. I always use Mod_Rewrite for everything :) - Hades666
0
sukhvinderkumarAuthor Commented:
This is my VirtualHost entry :

<VirtualHost x.x.x.x:80>
        ServerName blog.test.com
        ServerAdmin it@test.com
        DocumentRoot /var/www/html/blog/
        <Directory "/var/www/html/blog/">
                DirectoryIndex index.php
                AllowOverride None
                Order allow,deny
                Allow from all
        </Directory>
        #Redirect permanent http://blog.test.com/blog/sms  http://blog.test.com/blog/?page_id=36  /var/log/httpd/
        #RewriteEngine On
        #RewriteLog /var/log/httpd/rewrite.log
        #RewriteLogLevel 9
        #RewriteMap escape int:escape

        #RewriteEngine On
        #RewriteRule ^blog/sms$  /blog/?page_id=36 [R=301,L]
        Redirect 301 /blog/sms http://blog.test.com/blog/?page_id=36

        ErrorLog logs/blog_error_log
        LogLevel warn
        LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
        LogFormat "%h %l %u %t \"%r\" %>s %b" common
        LogFormat "%{Referer}i -> %U" referer
        LogFormat "%{User-agent}i" agent
        CustomLog logs/blog_access_log combined
</VirtualHost>

And i restarted apache also.

But getting the same

"Not Found

The requested URL /blog/sms was not found on this server."

Actually the page sms also doesn't exists.
0
arober11Commented:
Have you loaded the modules e.g.

LoadModule rewrite_module                 /usr/lib64/apache2-prefork/mod_rewrite.so
or:
LoadModule alias_module                   /usr/lib64/apache2-prefork/mod_alias.so

Note: The module loads need to appear outside the Virtual host defenition.

Oh, if your adding a RewriteRule inside a xxxx.conf file you need to include the leading '/' e.g.

RewriteEngine On
RewriteRule ^/blog/sms$  /blog/?page_id=36 [L]

You should test your httpd.conf changes before attempting to re-start the server, by doing something along the following lines:

/etc/init.d/apache2  test
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Java App Servers

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.