[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 366
  • Last Modified:

apache, perl, rewriting rules

Hi, I'm currently trying to figure out how to do a rewrite on my wordpress which is on apache 2.0 fedora 5.

It is not connected to the Internet.

So how do I perform a rewrite on apache 2.0

I need to convert

http://192.168.xxx.xxx/wordpress/?post_id

to

http://192.168.xxx.xxx/wordpress/post_id/post)name

thanks a lot!
0
shortandsharp
Asked:
shortandsharp
  • 4
  • 3
1 Solution
 
ravenplCommented:
create .htaccess file in Your wordpress flolder with following content

RewriteEngine On
RewriteRule ^\?(.+) post_id/$1

But please fix Your example, it's unclear what exactly You want.
0
 
shortandsharpAuthor Commented:
okay example

from

http://192.168.123.237/wordpress/?p150

to

http://192.168.123.237/wordpress/150/if-your-scanner-software-is-not-online-please-buy-a-new-scanner

where p150 = pid
and
if-your-scanner-software-is-not-online-please-buy-a-new-scanner = postname

thanks
0
 
ravenplCommented:
> where p150 = pid
> and
> if-your-scanner-software-is-not-online-please-buy-a-new-scanner = postname
What is pid and postname?
0
Free Backup Tool for VMware and Hyper-V

Restore full virtual machine or individual guest files from 19 common file systems directly from the backup file. Schedule VM backups with PowerShell scripts. Set desired time, lean back and let the script to notify you via email upon completion.  

 
shortandsharpAuthor Commented:
http://codex.wordpress.org/Using_Permalinks

pid is %post_id%

postname is  %postname%

thanks
0
 
ravenplCommented:
So You rather want the url
http://192.168.123.237/wordpress/150/if-your-scanner-software-is-not-online-please-buy-a-new-scanner
to be rewritten to
http://192.168.123.237/wordpress/?pid=150&postname=if-your-scanner-software-is-not-online-please-buy-a-new-scanner
Right?

#wordpress/.htaccess
RewriteEngine On
 RewriteRule ([^/]+)/([^/]+) script_handler.pl?pid=$1%postname=$2 [L]
0
 
shortandsharpAuthor Commented:
no,

in general it means

http://192.168.123.237/wordpress/150/if-your-scanner-software-is-not-online-please-buy-a-new-scanner
to be rewritten to
http://192.168.123.237/wordpress/?pid=150

if another post

http://192.168.123.237/wordpress/149/buy-dish-network
to be rewritten to
http://192.168.123.237/wordpress/?pid=149

this concerns wordpress way of doing things, I'm figuring out how do the host do the rewrite.

Rewrite is different from redirection.

Rewrite actually  means if I display

http://192.168.123.237/wordpress/149/buy-dish-network

then it will be

displaying content from http://192.168.123.237/?p=149

thanks
0
 
ravenplCommented:
My last rewriteRule does exactly the thing. In addition to pid it gives postname as well. Oh, You wanted $p variable, not $pid.
#wordpress/.htaccess
RewriteEngine On
 RewriteRule ([^/]+)/([^/]+) script_handler.pl?p=$1%postname=$2 [L]
 #please change script_handler.pl to real handler, propably index.cgi or index.php
0

Featured Post

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

  • 4
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now