php - getting stuck for change files url in .htaccess -
i new in .htaccess file, want change every file different url 1st default use work 1 file
rewriterule ^([a-za-z0-9-/]+).html$ xrl.php?xrl=$1
then change contactus.php file url google below
rewriterule ^contact-us$ contact.php [l]
its not work method more try whole website not work. how change every file different url want.
we can rewrite urls using .htaccess files. before writing in .htaccess files need verify kind of server using. here in case may use either apache server or nginx server. can check adding
<?php phpinfo(); ?> in php page.
case 1 : apache server:
ensure mod_rewrite module enabled in apache server. can identified checking phpinfo included page.
common methods used url rewriting follows
rewriteengine
this mandatory apache server. used enable rewriting engine. in cases should on default.so ensure following code must mandatory in top of htaccess file
rewriteengine on rewriterule
in cases may have few pages , can specify each page in website in .htaccess file. in such case can use these kind of rewriting example
rewriterule ^article/used/to/be/here.php$ /article/now/lives/here/ [r=301,l]
suppose have rewrite url these
http://en.wikipedia.org/wiki/url_rewriting you should write these on .htaccess file
rewriteengine on rewriterule ^wiki/(.+)$ w/index.php?title=$1 [l] but actual implementation of page these
http://en.wikipedia.org/w/index.php?title=url_rewriting
rewritecond
this can used rewriting url respect conditions. suppose need add or remove www website name , on condition redirect page "url not available or error message "
example :
rewritecond %{http_referer} !^http://(www.)?example.com/.*$ [nc] you can further refer here
case 2 : nginx server
enable module httprewritemodule on nginx server use location rewrite urls per nginx settings
example
location / { root /path/to/drupal; index index.php index.html; try_files $uri $uri/ @rewrite; } location @rewrite { rewrite ^/(.*)$ /index.php?q=$1; }
Comments
Post a Comment