本文介绍了使用MOD-重写,5页(通配符子域)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! 比方说,我有5页(的index.php , about.php , portfolio.php , gallery.php , contact.php )。Let's say I got 5 pages (index.php, about.php, portfolio.php, gallery.php, contact.php).让我们说的id是 1 。原始URL是: www.domain.com/folder/index.php?id=1 , www.domain.com/folder/about.php?id=1等等...现在,我想将其更改为:Now, I want to change it to : 1.domain.com/index , 1.domain.com/about , 1.domain.com/portfolio , 1.domain.com/gallery , 1.domain.com/contact是否有可能与国防部重写?如果我在的index.php 页,最新的&LT; A HREF =&GT; 的进入 about.php 如果国防部重写是可能的吗?Is it possible with mod-rewrite ? And if I'm in the index.php page, whats the <a href="" > that goes to about.php if the mod-rewrite is possible?非常感谢你:DI AP preciate您的帮助:DThank you very much :D I appreciate your help :D 修改还有一件事,我的通配符子域文件夹的public_html /文件夹/One more thing, My wildcard subdomain folder is public_html/folder/ 解决方案通过 AnubhavaThe Solution By Anubhava编辑的子域codeS:Edited with subdomain codes :Options +FollowSymLinks -MultiViewsRewriteEngine OnRewriteBase /# EDIT BY ANUBHAVA: to make http://1.domain.com/ load /about as default page# Replace /about with any other page you want as default pageRewriteCond %{HTTP_HOST} ^1\.(domain\.com$ [NC]RewriteRule ^$ /about [L]RewriteCond %{HTTP_HOST} !^www.domain.com$ [NC]RewriteCond %{HTTP_HOST} ^(www.)?([^.]+).domain.com$ [NC]RewriteRule ^(index|about|portfolio|gallery|contact)/?$ /$1.php?id=%2 [L,NC,QSA]请确保您的通配符子域目录中存放页面。也把你的.htaccess文件在该页面的目录。Make sure your wildcard subdomain directory is where the pages are. Also put your .htaccess file in the directory where the pages are.推荐答案到的httpd.conf 启用了mod_rewrite和.htaccess,然后把这个code在的.htaccess $ DOCUMENT_ROOT 目录下:Enable mod_rewrite and .htaccess through httpd.conf and then put this code in your .htaccess under DOCUMENT_ROOT directory:Options +FollowSymLinks -MultiViews# Turn mod_rewrite onRewriteEngine OnRewriteBase /# EDIT: to make http://1.domain.com/ load /aboutRewriteCond %{HTTP_HOST} ^1\.(domain\.com$ [NC]RewriteRule ^$ /about [L]RewriteCond %{HTTP_HOST} ^1\.(domain\.com$ [NC]RewriteRule ^(index|about|portfolio|gallery|contact)/?$ http://www.%1/folder/$1.php?id=1 [R=302,L,NC,QSA]一旦到位创建这样的href链接:Once that is in place create href links like this: &LT; A HREF =htt​​p://1.domain.com/about&gt;关于美国和LT; / A&GT; 或&LT ; A HREF =htt​​p://1.domain.com/contact&GT;联系我们&LT; / A&GT; 这篇关于使用MOD-重写,5页(通配符子域)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!
08-24 07:29