1

The hosting FAQ page found here http://www.freewebhostingarea.com/faq.html says:

Yes, we have full .htaccess support. Mod_rewrite is enabled and you will be able to use permalinks or any other rule.

So in my .htaccess file I have:

Options ExecCGI Includes IncludesNOEXEC SymLinksIfOwnerMatch -Indexes
#Options -Indexes
#Options All -Indexes     <------------- I've also tried these commented lines
ErrorDocument 404 /404.php      
RewriteEngine On      

# Taking the advice of early posters to simplify my two rules into one
# my current rewrite rule is:

RewriteRule ^([a-zA-Z0-9]+)/([0-9]+)/?$ viewpost.php?category=$1&number=$2

# Below were my original re-write rules when I posted this question: 
#RewriteRule ^([a-zA-Z0-9]+)/([0-9]+)$ viewpost.php?category=$1&number=$2
#RewriteRule ^([a-zA-Z0-9]+)/([0-9]+)/$ viewpost.php?category=$1&number=$2

The only line that works is the 404 page I put in (line 4), I assume I can't prevent a directory listing probably because the server doesn't allow overrides.

I can't actually find a statement anywhere that says I can't, but It's a free host, so I just assumed so.

But their FAQ specifically states I can use mod rewrite (maybe I'm misunderstanding?).

When I type in:

http://www.mywebsite.com/s/1

I simply get my 404 page rather than having it written to

viewpost.php?etc...

@user2734435 what is your folder structure?

I have most of my php files in my root folder. I have a folder for images, and I have a folder for post content for each category.

All the relevent files that I believe are immediately/obviously relevent for this problem are in the root folder (there may be other things that are relevent that I've missed, but I've tried to cover all my bases above). my viewpost.php, my .htaccess my 404.php (not really relevent but Included because that's the only line that DOES work as intended in the file.)

domain on public_html?

It's a free host. there's no public_html. The scope I have access to with this webhost is probably the public_html. I place my index in the "root" folder, and that's what shows up when visit my domain.

where is your php files?

"root" folder I described above.

where is your .htaccess file?

Root folder. I have no other .htaccess file

do you have any other .htaccess files on other directories?

See above.

4

2 回答 2

1
Options +FollowSymLinks -MultiViews

RewriteEngine On
RewriteBase /

ErrorDocument 404 /404.php
RewriteRule ^([^/]+)/([0-9]+)/?$ /viewpost.php?category=$1&number=$2 [L]

([^/]+)告诉您要捕获所有内容,而不是/1 美元。

([0-9]+)告诉您想要将任意数量的数字捕获为 2 美元。

/?意味着最后一个/是可选的。

简而言之,这条规则意味着:

domain.com/anythinghere/anynumberhere

或者

domain.com/anythinghere/anynumberhere/

重定向到:

domain.com/viewpost.php?category=anythinghere&number=anynumberhere
于 2013-08-31T05:05:18.927 回答
0

尝试这个

Options -Indexes +FollowSymLinks -MultiViews
RewriteEngine On      
RewriteRule ^([a-zA-Z0-9]+)/([0-9]+)/?$ viewpost.php?category=$1&number=$2
于 2013-08-30T22:28:44.470 回答