.htaccess - 重定向基地+短网址
问题描述
我正在尝试做一个简单的自定义 url shortner 。
我有这个需要重定向到的域“a.st”:“astrit.co”
如何创建重定向“a.st/234”>>“astrit.co/?p=234”
RewriteEngine on
RewriteCond %{HTTP_HOST} a\.st [NC]
RewriteCond %{REQUEST_URI} ^/$
Rewriterule ^(.*)$ https://astrit.co/ [L,R=301]
解决方案
你可以用这个
RewriteEngine on
RewriteCond %{HTTP_HOST} ^a\.st$ [NC]
RewriteRule ^(234) http://astrit.co/?p=$1 [L,R]
推荐阅读
- loops - 从单个数据集创建多个 SAS 宏变量列表
- javascript - 使用javascript在chrome或firefox(均为最新版本)上自动打印pdf文件
- macos - macOSX 上“LWP::Protocol::https 未安装”的哪个自制软件包?
- r - `as.Date()` 返回 `NA` 而不是字符串“2012-01”的日期对象
- javascript - 在 Lodash 中从字符串数组转换为 hashmap
- javascript - 什么是 JavaScript 中的“导出”?
- php - 如果用户输入正确的值,如何清除服务器端验证错误消息?
- wordpress - 如何用正斜杠(/)替换破折号(-),但如果可能,url应该在.htaccess中作为破折号工作
- json - 如何使用 jq 在 json 中创建对象的键?
- node.js - Convert stdout to JSON