Technical interview questions for software engineers — languages, databases, web, cloud, DevOps, and fundamentals. Browse all topics.

  • PHP Interview Questions

  • OOP Interview Questions

  • jQuery Interview Questions

  • MySQL Interview Questions

  • JavaScript Interview Questions

  • HR Interview Questions

  • HTML Interview Questions

  • C/C++ Interview Questions

  • Showing posts with label 301 Redirect. Show all posts
    Showing posts with label 301 Redirect. Show all posts

    How to enable .htaccess in wamp server

    How to enable .htaccess in wamp server
    In this article,I will explain how to enable .htaccess in wamp server.


    1. Open wamp_server  (Go to Wamp -> Right click at icon in the taskbar=> Apache=> httpd.conf)



    Bookmark and Share

    .htaccess file and URL rewrite rule in php


    .htaccess file and URL rewrite rule in php

    Redirect URLs using .htaccess  :   
    You can use .htaccess to redirect users to a different URL(redirect a url)    
    Sometimes you need to redirect some URL and/or page on your site to another one.    
    using the “Redirect” directive:    
       
    Redirect /folder http://www.example.com/newfolder      
       
    Another useful directive is the RedirectMatch    
       
    RedirectMatch "\.html$" http://www.example.com/index.php      
       
    This will redirect all requests to files that end with .html to the index.php file.      
    One of the more powerful tricks of the .htaccess hacker is the ability to rewrite URLs    
       
    simple rewriting        
    all requests to whatever.htm will be sent to whatever.php:    
    Options +FollowSymlinks      
    RewriteEngine on      
    RewriteRule ^(.*)\.htm$ $1.php [NC]      
    RewriteRule ^menu.html menu.php      


    Bookmark and Share

    A .htaccess rule that will divert any page in another folder

    A .htaccess rule that will divert any page in another folder


    1)If you want to redirect http://test.com/f1/  to  http://test.com/f2/.
     .htaccess file will be.

    Options +FollowSymLinks
    RewriteEngine On
    RewriteRule ^f1.*$ http://test.com/f2/ [R=301,L]


    2)If you want to redirect http://test.com/f1/test.html to http://test.com/f2/test.html.
     .htaccess file will be.

    Options +FollowSymLinks
    RewriteEngine On
    RewriteRule RewriteRule ^f1/(.*)$ http://test.com/f2/$1 [R=301,L]

    3) If you want to redirect http://test.com/ to http://www.test.com/.
     .htaccess file will be.


    Options +FollowSymLinks
    RewriteEngine on
    RewriteCond %{HTTP_HOST} ^test.com [NC]
    RewriteRule ^(.*)$ http://www.test.com/$1 [R=301,L]

    4) If you want to redirect  http://test.com/ to https://test.com/.

     .htaccess file will be.
    RewriteEngine On
    RewriteCond %{SERVER_PORT} 80
    RewriteRule ^(.*)$ https://www.test.com/$1 [R,L]


    Bookmark and Share