5 examples of common Rewrite URL using htaccess
Hello to you, especially as you have been and will be a webmaster icon smile 5 examples of common Rewrite URL using htaccess
You are a WM would of course have the focus to promote your website to attract traffic. There are many factors to achieve the requirement that within the framework of this limited English Coding article could not say. Vietnam Coding only referring to the “rewrite” (rewrite) web link (url) of your beautiful, easy to remember, are generally friendly. Friendly to both the visitor and the search engine. You think if I had to type in manually or copy paste in your browser address line:
or you simply want to type something like this:
/ Article/25/bai-hoc-tu-cuoc-song /
I need answers on your behalf? icon biggrin 5 examples of common Rewrite URL using htaccess
The following article will guide you to use the power of the. Htaccess, which posts a link to your website in a friendly manner (friendly url).
Hope you do not forget an article of the Viet Coding talking about. Htaccess: Protect your bandwidth Weblog with htaccess?
urllarge 5 examples of common Rewrite URL using htaccess
URL Rewriting – An important technique for SEO – (Source: Internet)
This is the fifth most common examples:
1. product-12.html”>product.php? id = 12 -> product-12.html
This is a very basic example of url rewrite, is often used to hide PHP extension:
RewriteEngine on
RewriteRule ^ product-([0-9] +). Html $ product.php? Id = $ 1
2. product/ipod-nano/12.html”>product.php? id = 12 -> product/ipod-nano/12.html
A professional SEO always cleverly display the main keyword in the URL. As in the following example, the URL displays the name of the product:
RewriteEngine on
RewriteRule ^ product / ([a-zA-Z0-9_-] +) / ([0-9] +). Html $ product.php? Id = $ 2
3. www URL”>Non www URL -> www URL
If you want the visitor typed into the browser theme4u.biz shall be transferred from www.theme4u.biz but the configuration is as follows:
RewriteEngine On
RewriteCond% {HTTP_HOST} ^ theme4u.biz$
RewriteRule (. *) Http://www.theme4u.biz/ $ 1 [R = 301, L]
4) theme4u.biz / user.php? Username = xyz -> theme4u.biz / xyz
If your site has a large number of members (such as social networking, forums), this is a great way to shortened links for members to remember
RewriteEngine On
RewriteRule ^ ([a-zA-Z0-9_-] +) $ user.php? Username = $ 1
RewriteRule ^ ([a-zA-Z0-9_-] +) / $ user.php? Username = $ 1
5) Transfer the domain to the directory:
In the process of website development, there is always a change (source code, database, site structure, etc.). Example theme4u.biz before still running in the root directory (root), suppose that for some reason the, Viet Coding root for and want to transfer the current Weblog directory / blog /?
RewriteEngine On
RewriteCond% {HTTP_HOST} ^ $ theme4u.biz [OR]
RewriteCond% {HTTP_HOST} ^ www.theme4u.biz $
RewriteCond% {REQUEST_URI}! ^ / Blog /
RewriteRule (. *) / Blog / $ 1
That’s it! From this all queries to theme4u.biz or www.theme4u.biz be redirected to theme4u.biz / blog
Of course, URL rewriting varied and rich, depending on the creativity of each webmaster that will give a unique url will not touch the goods, such as:
http://abc.com/Music/ # List_Album2, -1.1
http://abc.com/Products/ # IPhone | 3GS | 32G
[Help] Property is typical is not it? What are you waiting for?
Bạn ơi, không có code php nào để ví dụ à??
đây không phải code php mà là một loại code trong file .htacess, file này nằm ở ngoài thư mục gốc của website với tên là .htaccess, nó không có tên mà chỉ có đuôi mở rộng. Nếu trong wordpress thì khi bạn chọn load permalink là “postname” thì file htaccess có nội dung như sau:
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ – [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
bạn đưa mấy dòng code trong bài này đưa vào file .htccess và thử sẽ biết ngay, cũng dễ mà
.htaccess bạn cách nào rewrite search url từ “%20” -> “+” ?
có đó bạn, bạn dùng thử cái này xem
RewriteRule ^+(.*)$ %20$1 [L]
chúc bạn thành công
Mình đã đưa vào lại bị lỗi? Mình làm trên opencart? hướng dẫn giúp mình. Cám ơn bạn nhiều
Server error!
The server encountered an internal error and was unable to complete your request. Either the server is overloaded or there was an error in a CGI script.
If you think this is a server error, please contact the webmaster.
Error 500
localhost
01/14/14 23:10:47
Apache/2.2.21 (Win32) mod_ssl/2.2.21 OpenSSL/1.0.0e PHP/5.3.8 mod_perl/2.0.4 Perl/v5.10.1
Bạn có thể trả lời giúp mình không?
file .htaccess của mình bị lỗi quy về 500 sửa ntn vậy ae
File htacces của mình bị lỗi. Nó báo web mình bị lỗi 500 là sao vậy mọi người