3

私の正規表現は、すべての結果を照合してページにリダイレクトしようとします。リクエストされたアドレスをページに送信したい:

RewriteRule ^/[\w\W]*$ processor.php [R,NC,L]

たとえば、私の住所は次のとおりです。

www.mywebsite.com/mySecretCode123

PHPファイルで読み取れるようにしたい:

<?php echo $mySecretCode123; /* outputs 'mySecretCode123' */ ?>

これどうやってするの?

4

2 に答える 2

3

.htaccesses

# RewriteCond is condition - make rewrite only if file doesn't exists
# (.+) means "any character, one or more"
RewriteCond  %{REQUEST_FILENAME} !-f 
RewriteRule ^(.+)$ processor.php?mySecretCode=$1 

PHP

<?php echo $_GET['mySecretCode']; ?>
于 2012-08-31T13:33:49.047 に答える
2

mod_rewrite と .htaccess を有効にしてからhttpd.conf、このコードをディレクトリの.htaccess下に配置します。DOCUMENT_ROOT

Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /

# If the request is not for a valid directory
RewriteCond %{REQUEST_FILENAME} !-d
# If the request is not for a valid file
RewriteCond %{REQUEST_FILENAME} !-f
# If the request is not for a valid link
RewriteCond %{REQUEST_FILENAME} !-l

RewriteRule ^(.+)$ processor.php?$1=$1 [L,QSA]
于 2012-08-31T13:48:32.507 に答える